-
Notifications
You must be signed in to change notification settings - Fork 26.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NEXT-601] search params object is empty in production with next 13 app dir #43077
Comments
Strange, Your link does seem to have valid search params when running. However my app on a newer canary version still seems to have the same issue of empty searchParams when running on Vercel. |
Ran into this on Next 13.0.5 last night. Works fine locally, but returns |
Solution. In dev mode searchParams was given, but not in build mode. If you use a client component you need to use the useSearchParams hook: https://beta.nextjs.org/docs/api-reference/use-search-params Also be aware of the getter-API, you can't access searchParams directly. |
Can confirm the same issue. Works fine if I "run dev" but returns empty after "run build" then "run start" |
same +1 |
Same, it does not work when deployed on Vercel... |
Search params object is empty after running commands next build, next start |
any solution for this problem !! |
With nextjs version 13.0.6 searchParams seem to work as expected. The versions after seem to have this bug |
Same thing. Any solution other than rolling back the version. |
+1. |
Can confirm that it is not only a problem with"app" dir, the issue also happens in "pages" dir. But only upon navigation to index path: (href="/"). |
+1 |
1 similar comment
+1 |
A similar issue is occurring with layout files, when calling an async function, the call is made at build time and then serves the same response on each call. Do not have this issue when dealing with dev. |
can confirm the error is happening, can also confirm that the version 13.0.6 is also having this issue in the reproduction link (opposing Waqas-Abbasi comment) |
@ijjk is there any update on a fix for this? |
@ijjk This is a major issue, breaking essential functionality so I would imagine so. |
I noticed that on some pages everything works for me, but on others (mostly where 4-5 requests to the API) it does not work. |
Thanks for flagging this folks, we will investigate 🙏 |
Will the issue be resolved in the next update? |
This comment was marked as spam.
This comment was marked as spam.
You may have to force page to be dynamic to get query params. This can be done by exporting variable named export const dynamic='force-dynamic';
export default function Home(props: unknown) {
return (
<main>
<pre>
{JSON.stringify(props, null, 2)}
</pre>
</main>
)
} Originally posted by @hubertlepicki in #44005 (comment) |
Pagination, for one example? If you have a URL with |
The ability to specify static searchParams along with params would be great. |
Exactly this. Our users share their searches with each other frequently, having cached versions of those pages takes a load off the server. |
I don't think either of you understand what the issue is here, searchParams are empty if you do not force-dynamic, so your page param will never reach your route. Of course for data loading you don't always want it to be dynamic... |
When will they solve this! Should be fixed asap |
Also having same issue.. ! |
Ensures that using `searchParams` opts into dynamic rendering. Fixes #43077 fix NEXT-601 ([link](https://linear.app/vercel/issue/NEXT-601)) <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: --> ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
Is this issue fixed yet? |
it still doesn't work on canary for you @Annukul? |
@IonelLupu Saw that this was just closed 3 days ago. I have upgraded my nextjs version from v13.1.6 to v13.2.4. Let's hope it works |
@Annukul try canary. Not 13.2.4. You will see 13.2.4 was released a week ago and this issue was fixed 3 days ago. Which means the fix is not yet officially released. |
@IonelLupu It's not working in v13.2.4. How can I use canary? Also is it safe to use the canary branch? It might have more issues before release |
The latest canary version (v13.2.5-canary.21) works for the most part, but in dev mode (npm run dev) I get an error message on pages using the searchParams: Dynamic server usage: searchParams.p After refreshing the page it works fine and production everything works fine as well. |
Even with the latest canary, and force-dynamic, still having issues with this.
formattedQueryParams is empty |
|
Hello there. I'm not sure how this is related, or if I'm doing something wrong, but I'm encountering a similar issue, with:
Accessing Here's the relevant NextRequest
If I Edit: Same issue with Next 13.2.x. |
In development, RSC searchParams works without any additional configuration but production build searchParams not work in same conditions. Only works when I set:
Is this intended? I don't so as documentation explains... |
Apparently so. Personally, I'm not a have of having to use to different apis to get the data and having to figure out which to use in which content ( server / client ). It all seems rather, messy |
is this issue solved? at the latest version? |
I hope not, this makes every page dynamic (i.e. partially uncachable) that might have a filter or pager in the query parameters for example. |
If you're running into an issue please open a new one with a reproduction, happy to have a look! |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP Fri Apr 2 22:23:49 UTC 2021
Binaries:
Node: 18.8.0
npm: 8.19.2se
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 13.0.4
eslint-config-next: 13.0.4
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
search params object is empty in production with next 13 app dir
Its ok if its a dynamic route
Expected Behavior
search params object is not empty in production
Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster
https://stackblitz.com/edit/nextjs-ncgro9?file=app/page.tsx
To Reproduce
npm run build && npm run start
go to /?page=1
go to /products/1?page=1
From SyncLinear.com | NEXT-601
The text was updated successfully, but these errors were encountered: