Next.js Discord

Discord Forum

Development time only pages

Unanswered
Golden-winged Warbler posted this in #help-forum
Open in Discord
Golden-winged WarblerOP
Is there a way to have pages only render when in development mode?

I have two scenarios
1. dev pages to help with debugging
2. pages that are not ready for production, but we want on the git trunk

1 Reply

Golden-winged WarblerOP
You can implement this concept by hand using the following snippet in next.config.js

  pageExtensions:
    ['jsx', 'js', 'tsx', 'ts', 'mdx', 'md']
      .map((ext) => {
        const draftMode = process.env.NEXT_DRAFT_MODE
        if (draftMode) { 
          return [ext, `draft.${ext}`]
        } else {
          return ext
        }
      })
      .flat()
    ,


This also means you can get pretty sophisticated about it too