cloudflare / cloudflare/vinext

Static pre-rendering at build time

Open
#9 8 comments 21 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
8.8k
Forks
406
Avg merge
2d 6h
Merged PRs (30d)
120

Description

## Summary

Next.js pre-renders static pages to HTML at build time. Pages without dynamic data fetching get rendered once during `next build`, and the resulting HTML is served directly without any server-side work at request time.

vinext currently does not do this. All pages are server-rendered on the first request, then cached via ISR. This works well for most apps, but purely static sites don't get the benefit of zero-compute serving from the start.

## Why it matters

- **Performance**: Pre-rendered HTML can be served from a CDN edge with zero compute cost at request time.
- **Feature parity**: `generateStaticParams()` is a commonly used Next.js API. Supporting it expands the set of apps that can migrate to vinext without changes.
- **Build comparison**: Part of Next.js's build time is spent pre-rendering. Adding pre-rendering to vinext would make build time comparisons more complete.

## Current workaround

vinext supports ISR out of the box. After the first request to any page, it's cached and revalidated in the background. For most production apps with any amount of traffic, the practical difference is minimal: one cold render per page after deploy.

For sites that are 100% static content with no dynamic routes, a static-first framework like [Astro](https://astro.build/) may be a better fit today.

## What pre-rendering would look like

- During `vinext build`, identify pages that are fully static (no `cookies()`, `headers()`, dynamic data fetching, etc.)
- Render those pages to HTML and write to the output directory
- For pages with `generateStaticParams()`, enumerate the params and pre-render each variant
- The production server serves pre-rendered HTML when available, falling back to SSR for dynamic pages

## Traffic-aware Pre-Rendering (TPR)

We're also experimenting with an alternative approach: instead of pre-rendering every page at build time, query Cloudflare's zone analytics to identify which pages actually receive traffic and only pre-render those. See the blog post for details.

This is available today behind `vinext deploy --experimental-tpr`.

## Status

This is on the roadmap. Contributions welcome.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.