Search params are undefined when draft mode is enabled #70384
Replies: 5 comments 2 replies
-
As an aside, how actively are these issues monitored? I've submitted 2 bugs months ago which have yet to be acknowledged by a maintainer |
Beta Was this translation helpful? Give feedback.
-
Edited to add an example of a production build run locally which also works as expected, which confirms a discrepancy between a production app built and run locally vs on Vercel |
Beta Was this translation helpful? Give feedback.
-
@MangoMarcus Actively as possible! We are currently taking a look at this. |
Beta Was this translation helpful? Give feedback.
-
Thanks @samcx 🙏 |
Beta Was this translation helpful? Give feedback.
-
@MangoMarcus It turns out your page was not bailing out of ISR (static) because I tried just adding:
Afterwards, token is no longer I am curious though as to why you want to access your |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Link to the code that reproduces this issue
https://github.com/MangoMarcus/nextjs-draft-mode-empty-search-params
To Reproduce
npm i
andnpm run dev
Current vs. Expected behavior
Locally the token correctly displays as 'foo' with draft mode enabled, but on Vercel it's 'undefined'. Vercel should also show 'foo'.
Interestingly there's also a discrepancy between
urlPathname
andisRevalidate
between local and vercel shown in the screenshots belowLocal - dev mode (
npm run dev
)Draft mode disabled

Draft mode enabled

Local - production build (
npm run build && npm start
)Draft mode disabled

Draft mode enabled

Vercel
Draft mode disabled

Draft mode enabled

Provide environment information
Which area(s) are affected? (Select all that apply)
Output (export/standalone), Runtime
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed)
Additional context
The problem might stem from the search parameter being accessed dynamically, depending on if draft mode is enabled.
If draft mode is enabled then the page is rendered dynamically and dynamic features like search parameters and cookies should be available. If it's disabled, then it's rendered statically and all search parameters should returned
undefined
.My example shows that draft mode is correctly enabled - and therefore the page is being rendered dynamically at request time - but the dynamic features are not available.
Edit: Added local production build examples
Beta Was this translation helpful? Give feedback.
All reactions