Skip to content

feat: serve site from a live Nuxt Content v4 surface (exploration) - #2661

Draft
atinux wants to merge 4 commits into
mainfrom
feat/content-v4-live-surfaces
Draft

atinux wants to merge 4 commits into
mainfrom
feat/content-v4-live-surfaces

Conversation

@atinux

@atinux atinux commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Written by an AI agent (Amp) on behalf of @atinux. @atinux has not reviewed it yet.

Exploration, not for merge. It tries nuxt/content-v4-temp#42 (live content surfaces) on nuxt.com, through its preview build @nuxt/content4@3744e90, which also includes nuxt/content-v4-temp#58 (createNuxtContent() typed by name). It doesn't touch #2621.

The first attempt to move site to Nuxt Content v4 was reverted: the module bundled site with the build, and vercel.json skips deploys for content-only pushes, so those edits never went live. With #42, site is a live surface: each request is served at the commit main's content last changed in, and a cold start hydrates from a build snapshot stamped with a commit.

What changed

  • server/content.ts: site is the module's content export, with live.ref resolving the commit through the same ref pointers as the other instances (resolveInstanceSha('site')).
    • The module calls live.ref on each request, so the pointer is read each time, as getInstanceAtHead() does for the other instances.
    • The module's own copy of the file reads the checkout in dev. It never calls live.ref, and site is typed from its declared schema, so the generated types no longer list its paths.
    • Gaps worked around, as in the first attempt: a no-op external-links plugin, and a typegen:field hook to open the generated types.
  • Push webhook (server/api/revalidate.post.ts): unchanged from main, and site stays in it. It moves the pointer, which every process reads on its next request, and warms a separate instance at the pushed commit.
  • getInstanceAtHead('site') returns resolveContent(content), and contentInstanceAt('site', sha) returns content.withRef(sha).
    • No cast: with Display projects with searchbar #58, content is typed as an instance named site. It's imported from server/content.ts, because the app tsconfig also checks this file through Nitro's auto-import types, where content is the browser client.
    • Those two functions return AnyComarkContent: an instance named site isn't assignable to a ComarkContent named string. getInstanceAtHead() still returns ComarkContent.
  • modules/snapshot skips site: the module ships its snapshot.
  • App: useContent('site') is the module's client, and documents render with <ContentDocument>.
  • Patch: nuxt-agent-discovery@0.8.2 is patched to accept @nuxt/content v4.

Evidence

From a local production build (nuxt build, node-server preset) in an Amp orb, on 139bf45 with the preview build fbc7204:

  • Snapshot: prerendering /__nuxt_content/snapshot/site.json resolved the ref, so the snapshot is stamped with 08b79481, the last commit that touched content/ on main. It holds 182 items.
  • Pages: these answer 200 on the built server: /blog/v4, /deploy/vercel, /enterprise/agencies, /design-kit, /team, /sponsors, /design.md, /raw/blog/v4.md and /__nuxt_content/get/blog/v4.
  • GitHub unreachable: with every request to api.github.com rejected, a cold start still answers 200 for /blog/v4, /raw/blog/v4.md and /__nuxt_content/get/blog/v4. The server logs once that it serves site at 08b79481, the snapshot's commit.
  • Checks: pnpm test:types, the unit tests (78 files, 827 tests) and eslint on the changed files pass.
  • On 3ade30e with 3744e90: pnpm test:types, the unit tests (78 files, 827 tests) and eslint on the changed files pass. Not built locally; the Vercel build and e2e check it.
  • Not checked on this commit: /, and the comparisons with production below.
  • Not tested here: the push webhook path and Vercel Runtime Cache. They need this preview and a push.

From the first build of this PR, with the preview build 6ca4a87:

  • /raw/blog/v4.md and /design.md are byte-identical to production, with no nofollow added.
  • /blog/v4 renders like production in screenshots, and its links have the same rel values.
  • / wasn't checked either. It waits on npm's download-stats API, which rate-limited the orb (429).

Found: content pages load more JavaScript

The bundle-size report on this PR builds main and this branch the same way and compares them (brotli). Client total: +73.4 kB (+5.6%). Initial page load:

Route Δ
/enterprise/agencies/:slug() +71.6 kB (+19.7%)
/deploy/:slug() +71.0 kB (+19.2%)
/design-kit +68.8 kB (+19.0%)
/docs/:slug(.*)* +45.1 kB (+10.8%)
/blog/:slug() +37.3 kB (+9.3%)

The likely cause is the module's component map, used by <ContentDocument>. It statically imports every app/components/content/ component, including Sandbox.vue (StackBlitz), while nuxt.com's per-page markdownComponents maps only load what each page lists. In a local build, /blog/v4 preloaded a StackBlitz chunk and a 224 kB three.js chunk that production doesn't. This comes from the v4 module's component map, not from live: with site not live, the preloads were about the same.

An earlier version of this description said /blog/v4 preloads 3.6× more JavaScript. That compared a local node-server build against production, not like for like; the report above is the fair comparison.

Still to do before nuxt.com could adopt v4

  • The component map above.
  • external-links can't be turned off, markdown can't take listingFields, and types are closed with an explicit schema.
  • Only site moved. The docs, cli, examples and module docs instances could become extra live surfaces with their own base paths, which feat(auth): email login #42 supports. nuxt.com's routing, pull previews and l10n assume its own handlers, so that is a larger change.

Exploration of nuxt/content-v4-temp#42 on nuxt.com: `@nuxt/content` v4
owns nuxt.com's own content (`site`) in `server/content.ts`, as a live
surface. The app reads it through the module's `content` client and
renders documents with `<ContentDocument>`. The docs, cli, examples and
module docs instances stay on comark-content.

- `live.ref` resolves `site` through the same ref pointers as the other
  instances (`resolveInstanceSha('site')`), so a content-only push is
  served once the push webhook moves the pointer, without a deployment.
  The webhook also pins its own process with `revalidateContent()`.
- The module ships `site`'s build snapshot, stamped with the commit
  resolved on build; `modules/snapshot` skips `site`.
- The module's copy of `server/content.ts` (types, dev) reads the
  checkout.
- Patch nuxt-agent-discovery 0.8.2 to accept `@nuxt/content` v4.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1ba1f-8ebe-766e-8f0e-204cf68f9904
@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nuxt Ready Ready Preview Nov 19, 2026 5:14pm UTC

Request Review

@nuxt-com-bundle-report

Copy link
Copy Markdown

Bundle size

Explore the comparison →

Client 1.38 MB $\color{red}\textsf{(+73.4 kB, +5.6}\%\textsf{)}$ · Server 9.14 MB $\color{green}\textsf{(-2.36 kB, -0.0}\%\textsf{)}$

Initial page load PR Δ
/enterprise/agencies/:slug() 434.7 kB +71.6 kB (+19.7%)
/deploy/:slug() 440.3 kB +71.0 kB (+19.2%)
/design-kit 430.0 kB +68.8 kB (+19.0%)
/docs/:slug(.) 464.6 kB +45.1 kB (+10.8%)
/dashboard/chat/:id() 634.8 kB +39.5 kB (+6.6%)
/blog/:slug() 439.2 kB +37.3 kB (+9.3%)
/nuxters 395.1 kB +19.3 kB (+5.1%)
/templates/:slug() 324.8 kB +18.9 kB (+6.2%)
/admin/analytics 474.5 kB +17.6 kB (+3.9%)
/dashboard/chat 473.5 kB +15.6 kB (+3.4%)

And 330 more routes.

Largest changes in the client
Package or file Base PR Δ
[unassigned] 131.8 kB 166.0 kB +34.3 kB (+26.0%)
node_modules/eve 81.4 kB 96.1 kB +14.8 kB (+18.1%)
node_modules/reka-ui 102.1 kB 93.2 kB −8.94 kB (−8.8%)
node_modules/@tanstack/charts 33.0 kB 40.2 kB +7.22 kB (+21.9%)
.nuxt/content/components.mjs n/a 3.73 kB +3.73 kB
node_modules/@nuxt/ui 88.6 kB 91.3 kB +2.72 kB (+3.1%)
node_modules/@comark/vue 2.19 kB 3.62 kB +1.44 kB (+65.7%)
node_modules/zod 21.8 kB 22.6 kB +868 B (+4.0%)
app/components/AdminAnalytics.vue 1.75 kB 2.62 kB +867 B (+49.5%)
layers/nuxi/app/composables/useNuxiIcon.ts 2.38 kB 3.10 kB +726 B (+30.6%)

And 60 more packages or files.

Largest changes in the server
Package or file Base PR Δ
[unassigned] 7.82 MB 7.72 MB −93.4 kB (−1.2%)
node_modules/reka-ui 80.1 kB 99.9 kB +19.8 kB (+24.8%)
node_modules/@nuxt/ui 126.2 kB 136.9 kB +10.7 kB (+8.5%)
node_modules/eve 98.6 kB 107.8 kB +9.21 kB (+9.3%)
.nuxt/dist/server/client.precomputed.mjs 16.7 kB 25.4 kB +8.72 kB (+52.3%)
app/components/DocsL10nEditor.vue n/a 8.51 kB +8.51 kB
shared/utils/l10n-editor.ts n/a 3.72 kB +3.72 kB
app/components/AdminAnalytics.vue n/a 3.48 kB +3.48 kB
app/components/settings/SettingsDeleteAccount.vue n/a 3.47 kB +3.47 kB
app/components/feedback/FeedbackChart.vue n/a 3.33 kB +3.33 kB

And 105 more packages or files.

Brotli sizes. Changes under 100 B are left out of the tables. Initial page load counts the JavaScript and CSS a route loads before it renders. Measured by nuxt-bundle-analyzer for f80d5c5.

The preview build of nuxt/content-v4-temp#42 at fbc7204 calls `live.ref`
on every request, and drops `ttl`, `live: true` and pinning a commit
through `revalidateContent()`.

`site` now has one `live: { ref }` outside dev. The module's copy of
`server/content.ts` no longer calls `ref`, so it doesn't need its own
`live: true`.

The push webhook is back to what it is on `main`: it warms a separate
instance at the pushed commit. It read the instance `@nuxt/content`
serves `site` from and disposed it after warming it.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1eec3-272f-75f4-b9d7-264930c267d0
The preview build of nuxt/content-v4-temp#42 at 3744e90 includes #58:
`createNuxtContent()` returns an instance typed by its `name`, so
`content.withRef()` and `resolveContent(content)` need no cast.

`content` is imported from `server/content.ts` instead of auto-imported:
the app tsconfig also checks this file through Nitro's auto-import types,
and there `content` is the browser client. The functions returning `site`
return `AnyComarkContent`, since an instance named `site` isn't assignable
to a `ComarkContent` named `string`.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1eec3-272f-75f4-b9d7-264930c267d0

This branch was successfully deployed

1 active deployment
Preview — 3ade30e4 Deployed Nov 19, 2026 by vercel[bot] via e2e #10356
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant