[Next 13] Server Component + Layout.tsx - Can't access the URL / Pathname
Problem
Edit: Please see the response and solutions here: https://github.com/vercel/next.js/issues/43704#issuecomment-2090798307
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: [Next 13] Server Component + Layout.tsx - Can't access the URL / Pathname
It's extremely counter-intuitive that there's basically no way to get the pathName from a server-side component. usePathname should at the very least be callable from the server-side as well even if it hits a different code path.
Trust Score
12 verifications
- 1
It's extremely counter-intuitive that there's basically no way to get the pathNa
It's extremely counter-intuitive that there's basically no way to get the pathName from a server-side component. usePathname should at the very least be callable from the server-side as well even if it hits a different code path.
Validation
Resolved in vercel/next.js GitHub issue #43704. Community reactions: 407 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep