Feedback and questions about "Preview mode" - How would you use it for a whole stage instead of specific pages? #13589
Replies: 2 comments
-
It works exactly as I explained above and was very easy to setup for the whole stage, without needing any extra/fancy security token and such.
One issue though, is browser cache. If you go to any SSG page (they're all SSG, except when SSR is mentioned) like https://nrn-v2-mst-aptd-gcms-lcz-sty-c1-c546qce0r.now.sh/fr/examples/built-in-features/ui-components And then you change the color at https://nrn-admin.now.sh/#/Customer/ck73s1dqm2ue30b98uepy9is3, then you navigate on https://nrn-v2-mst-aptd-gcms-lcz-sty-c1-c546qce0r.now.sh, you'll notice the change isn't applied until you force reload (cmd+shift+r). Is there a way to avoid this issue when preview mode is enabled? Because my end users won't know it's a cache issue, and will struggle like crazy thinking their changes didn't work. Would be much smoother if that was the default behaviour, or if I could enforce it anyhow. |
Beta Was this translation helpful? Give feedback.
-
Here is our demo of the Preview mode, if you'd like to play around:
|
Beta Was this translation helpful? Give feedback.
-
I went through https://nextjs.org/docs/advanced-features/preview-mode and I understand the doc explains how to use the new Preview mode for specific routes.
For example when working on a Headless CMS which has the ability to embed a preview, it could display your web app with a page using the data you're recently updated in your CMS, without needing to rebuild the app.
The above example is the use-case that's featured by the documentation.
My use case is a bit different. My CMS doesn't have the ability to embed a preview, so I'm thinking about a different design.
There are three stages in my workflow:
What I would like is to make the whole "staging" stage using the Preview mode.
Thinking out loud, I believe I could check for the existence of
__prerender_bypass
and/or__next_preview_data
in the browser cookie, and redirect the user to the/api/preview
if one of those cookies is missing.This would enable preview mode for the whole session, and all pages should automatically use the preview mode (and thus, all pages would use the latest content automatically).
I'm thinking displaying a static message (like a header) stating "preview mode has been enabled", and maybe some toggle button (on/off) would improve end-user usability, and make testing easier.
Is it how preview mode was intended to be used?
Are there any cons about doing things this way?
How would you manually disable Preview mode? I'm thinking about deleting both cookies manually.
Beta Was this translation helpful? Give feedback.
All reactions