Local preview

Preview your theme and layout locally in the browser via the CLI before pushing to GitHub.

Run docs preview when you want to see layout and theme changes before pushing to GitHub. The CLI watches docs.json (or docs.yaml) and docs/**/*.mdx on your machine, renders each page with the same production content pipeline, and streams updates to the hosted preview UI.

For the full command workflow (flags, troubleshooting, and CI integration), see Preview locally on the CLI page.

Before you begin

For shareable branch and pull request previews after you push, see Branch preview.

Steps

  • Open a terminal at your project root

    Use the directory that contains docs.json.

  • Start the preview server

    bash
    npx @docs.page/cli preview

    The CLI starts a local WebSocket server, prints the socket URL, and opens your browser to a preview URL shaped like:

    text
    https://docs.page/preview?url=ws://localhost:57250

    The browser loads the production preview shell while file reads and bundling stay on localhost.

  • Edit and save

    Change any watched file under docs/ or update docs.json. The preview reloads without a Git push.

  • Customize port or browser behavior when needed

    bash
    npx @docs.page/cli preview --port 4000
    npx @docs.page/cli preview --no-browser

    Use --no-browser in remote development or when you want to copy the printed URL manually.

Verify

After the server starts, confirm:

  • The terminal shows Local preview server started and a Preview URL
  • The browser renders your home page with the correct project name and sidebar
  • Saving a visible change in docs/index.mdx updates the preview within a few seconds

Limitations

Local asset resolution in preview mode has known gaps. Prefer relative paths that match how files are laid out in your repository.

Troubleshooting

SymptomLikely causeFix
CLI exits before the server startsMissing docs.json or no .mdx under docs/Run init or add the required files
Browser shows a connection errorPreview server stopped or wrong URLRestart docs preview and open the newly printed URL
Port already in useAnother process bound the default portPass --port with a free port number
Preview looks staleEditor did not save the fileSave the file; confirm the terminal still shows the watcher running

Next steps