Skip to content
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.js router could have knowledge of preview mode #14903

Closed
Timer opened this issue Jul 7, 2020 · 1 comment · Fixed by #21638
Closed

Next.js router could have knowledge of preview mode #14903

Timer opened this issue Jul 7, 2020 · 1 comment · Fixed by #21638
Assignees
Milestone

Comments

@Timer
Copy link
Member

Timer commented Jul 7, 2020

Feature request

An application can only determine if you're in Preview Mode via getServerSideProps or getStaticProps.

This can lead to noisy prop drilling to render preview states in different parts of your application, and make it difficult to render something specific to preview mode in Custom <App> due to the lack of dedicated getServerSideProps or getStaticProps for that file.

Describe the solution you'd like

Next.js' router should provide preview state, similar to fallback state:

import { useRouter } from 'next/router';

const { isPreview } = useRouter();

We might also want the following to work:

import Router from 'next/router`
Router.isPreview

This is an API idea, we're not entirely sure if we want to implement this yet. Just braindumping here!

@Timer Timer self-assigned this Jul 7, 2020
@Timer Timer removed their assignment Jul 29, 2020
@Timer Timer modified the milestones: 9.x.x, iteration 6 Jul 29, 2020
@Timer Timer modified the milestones: iteration 6, iteration 7 Aug 6, 2020
@Timer Timer modified the milestones: iteration 7, 9.x.x Aug 18, 2020
@Timer Timer modified the milestones: 10.x.x, backlog, iteration 16 Jan 6, 2021
@ijjk ijjk self-assigned this Jan 28, 2021
@ijjk ijjk added the point: 2 label Jan 28, 2021
@kodiakhq kodiakhq bot closed this as completed in #21638 Feb 18, 2021
kodiakhq bot pushed a commit that referenced this issue Feb 18, 2021
This adds an `isPreview` field to the `next/router` to allow detecting when in preview mode. 

Closes: #14903
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants