Fix Next.js Pages Router pathname in AppProvider#4657
Fix Next.js Pages Router pathname in AppProvider#4657apedroferreira merged 3 commits intomui:masterfrom apedroferreira:fix-pages-router-pathname
Conversation
| */ | ||
| export function NextAppProviderPages(props: AppProviderProps) { | ||
| const { push, replace, asPath, query } = useRouter(); | ||
| const { push, replace, pathname, query } = useRouter(); |
There was a problem hiding this comment.
@Janpot is this ok or is there a reason why you were using asPath?
There was a problem hiding this comment.
is there a reason why you were using
asPath?
only short-sightedness 🙂
There was a problem hiding this comment.
I believe the reason for using asPath is that pathname has a different form when running a nextjs app with skipMiddlewareUrlNormalize: true option for dynamic routes — pathname would look like /route/[param] for route /route/[param].ts. I believe the older solution of asPath.split('?')[0] worked better.
There was a problem hiding this comment.
Hi, yes, that's actually something I reverted recently in the CRUD component PR as I noticed some issues with using pathname.
So in this upcoming release it will be asPath.split('?')[0] (we also didn't have the split with "?" before)
Netlify deploy preview |
Use
pathnamein Next.js Pages Router adapter.Closes #4645 (comment)