Skip to content

feat(docs): upgrade to Nextra 4 - #106

Merged
ASafaeirad merged 2 commits into
mainfrom
feat/nextra-4
Sep 10, 2026
Merged

ASafaeirad merged 2 commits into
mainfrom
feat/nextra-4

Conversation

@ASafaeirad

Copy link
Copy Markdown
Member

Closes #81

Nextra 4 drops the Pages Router entirely, so this is a structural migration rather than a version bump. URLs are unchanged (/array, /array/compact, …).

Routing / content

  • docs/pages/docs/content/, rendered through app/[[...mdxPath]]/page.tsx + mdx-components.ts
  • Section pages (array.mdx) became folder index pages (array/index.mdx) with asIndexPage: true front matter. Without that flag Nextra 4 renders each section twice in the sidebar — once as a folder toggle, once as a link.
  • All 14 _meta.json_meta.ts

Theme

  • theme.config.jsx is gone; its options are now props on <Layout> / <Navbar> / <Footer> / <Head> in app/layout.tsx, plus Next's metadata export for the SEO tags
  • global.css is gone too — it was entirely nx--prefixed class hacks that no longer exist. The background (rgb(35,37,46)) and primary hue (31) come from <Head> now; only the card border/radius tweak survives, in app/globals.css.

Build

  • next exportoutput: 'export'
  • Search moves FlexSearch → Pagefind via a postbuild script
  • Next 13 → 15, React 18 → 19, Tailwind 3 → 4
  • github-pages.yml runs npm run build, and uses fetch-depth: 0 so Nextra can read git history for per-page last-updated dates

Two things worth a look

zod is pinned to 4.3.6 via overrides. Nextra 4.6.1's <Layout> strips children before validating its props, but zod >= 4.4 made that key non-optional, so every page render throws. This is shuding/nextra#4989, unfixed in a release. The override can go once upstream ships a fix.

The navbar logo is a <span> instead of an <h1>. Pagefind uses a page's first <h1> as the search-result title, so with the old markup every search result was titled "Toolbox". Computed styles are identical — Tailwind preflight already reset it to 16px/400.

One behaviour change

The /node sidebar label now reads "Env" rather than "Node". Nextra 4 takes a section's label from its index page title, and that page's heading is # Env. Adding node: 'Node' to content/_meta.ts restores the old label if you'd prefer it.

Verification

vp check, vp run type-check and vp test (600 tests) all pass. The docs build produces 106 static pages with Pagefind indexing 105.

I served out/ and confirmed in-browser: dark theme forced with no flash, hue-31 accent, 12 cards on /array with the custom border, sidebar collapsed to level 1, syntax highlighting, copy buttons, the "Suggest a new function" link still pointing at the proposal issue template, edit links resolving to blob/main/docs/content/…, and Pagefind returning correct titles and URLs.

🤖 Generated with Claude Code

ASafaeirad and others added 2 commits September 10, 2026 15:27
Nextra 4 drops the Pages Router, so the docs site moves to the App Router
with the content directory convention.

- `pages/` -> `content/`, served through `app/[[...mdxPath]]/page.tsx`
- section pages (`array.mdx`) -> folder index pages (`array/index.mdx`)
  with `asIndexPage: true`, so each section stays a single sidebar entry
- `_meta.json` -> `_meta.ts`
- `theme.config.jsx` -> `<Layout>`/`<Navbar>`/`<Footer>`/`<Head>` props in
  `app/layout.tsx`, plus Next's `metadata` export for SEO tags
- search moves from FlexSearch to Pagefind via a `postbuild` script
- `next export` -> `output: 'export'`, so `npm run build` produces `out/`
- Next 13 -> 15, React 18 -> 19, Tailwind 3 -> 4
- `TOC` uses `Cards` from `nextra/components`
- global.css drops the dead `nx-`-prefixed overrides; the background and
  primary colors now come from `<Head>`

The navbar logo uses a `<span>` instead of an `<h1>`: Pagefind takes a
page's first `<h1>` as its search result title, and the navbar one made
every result read "Toolbox".

zod is pinned below 4.4 because Nextra 4.6.1's `<Layout>` rejects its own
`children` prop when validating against newer zod, which fails every page
render (shuding/nextra#4989).

Closes #81

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ASafaeirad
ASafaeirad merged commit 6724f3d into main Sep 10, 2026
2 checks passed
@ASafaeirad
ASafaeirad deleted the feat/nextra-4 branch September 10, 2026 13:48
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 4.25.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade docs to Nextra 4

1 participant