Static Export
vinext supports full static site generation, creating HTML files at build time that can be deployed to any static hosting provider—no server required.Overview
Static export renders all pages to HTML at build time, producing a directory of static files:- Deploy to any static host (CDN, S3, GitHub Pages)
- Maximum performance (no server rendering overhead)
- Zero infrastructure requirements
- Perfect for documentation sites, blogs, marketing pages
- No server-side rendering (SSR)
- No API routes
- No dynamic routes without
generateStaticParams()orgetStaticPaths() - No Incremental Static Regeneration (ISR)
Enable Static Export
Addoutput: 'export' to your Next.js config:
dist/ directory.
Pages Router
Static Pages
Regular pages are rendered to HTML automatically:dist/index.html.
Pages with Data (getStaticProps)
Fetch data at build time:getStaticProps runs at build time—the API is called once, and the result is baked into the HTML.
Dynamic Routes
Dynamic routes requiregetStaticPaths to specify which paths to generate:
fallback must be false for static export. No dynamic fallback pages are generated.
Catch-All Routes
Catch-all routes work the same way:dist/docs/getting-started.htmldist/docs/api/reference.htmldist/docs/guides/deployment/cloudflare.html
Not Supported with Static Export
getServerSideProps
Error:getServerSideProps requires a server.
getStaticProps instead.
API Routes
API routes are skipped with a warning:App Router
Static Pages
Server Components are rendered at build time:dist/index.html.
Pages with Data
Server Components can fetch data directly:Dynamic Routes
Dynamic routes requiregenerateStaticParams:
Catch-All Routes
Nested Dynamic Routes
For nested dynamic segments, use top-down params passing:Route Handlers (API Routes)
Route handlers are skipped with a warning:Static Metadata
Metadata is included in the generated HTML:Build Process
vinext performs the following steps during static export:1
Route Discovery
Scans your
pages/ or app/ directory to find all routes.2
Path Expansion
For dynamic routes, calls
getStaticPaths() (Pages Router) or generateStaticParams() (App Router) to expand all possible paths.3
Rendering
Renders each route to HTML:
- Pages Router: Calls
getStaticProps, renders with React SSR - App Router: Starts dev server, fetches each URL, saves HTML
4
Asset Copying
Copies static assets (JS, CSS, images) from
public/ and Vite build output to dist/.5
404 Page
Renders custom 404 page if present, otherwise uses default.
Deployment
Cloudflare Pages
Deploy thedist/ directory:
Vercel
Netlify
GitHub Pages
Add a workflow:gh-pages branch.
AWS S3 + CloudFront
Nginx
Copydist/ to your web server:
Advanced Configuration
Trailing Slash
Control URL format:trailingSlash: true:
/about→dist/about/index.html- Served as
/about/
trailingSlash: false (default):
/about→dist/about.html- Served as
/about
Base Path
Deploy to a subdirectory:/docs:
/→/docs//about→/docs/about
Image Optimization
Images are not optimized in static export. Options:-
Disable optimization:
- Use a CDN: Upload images to a CDN that handles optimization (Cloudflare Images, Imgix, Cloudinary)
- Optimize at build time: Use an image optimization tool before deploying
Common Patterns
Documentation Site
Blog with Pagination
Multi-Language Site
Troubleshooting
Build Error: getServerSideProps Not Supported
Error:Page uses getServerSideProps which is not supported with output: 'export'
Solution: Replace getServerSideProps with getStaticProps. Server-side rendering requires a server.
Build Error: Dynamic Route Missing Paths
Error:Dynamic route requires getStaticPaths with output: 'export'
Solution: Add getStaticPaths (Pages Router) or generateStaticParams (App Router):
404 on Dynamic Routes
Problem: Dynamic routes return 404 after deployment Solution: Most static hosts expect.html files. Configure your host to:
- Append
.htmlto paths without extensions - Use a rewrite rule:
/blog/post-1→/blog/post-1.html
/blog/post-1/index.html which is served as /blog/post-1/ by default.
Large Build Time
Problem: Static export takes a long time Solution: You’re generating many pages. Options:- Reduce the number of pages generated
- Use ISR instead (requires a server)
- Deploy to Cloudflare Workers for on-demand rendering
Data Not Updating
Problem: Content changes don’t appear after deployment Solution: Static export bakes data at build time. To update:- Rebuild:
vinext build - Redeploy the new
dist/directory
Next Steps
Deployment Guide
Deploy your static site to production
Configuration
Customize build and export settings
Cloudflare Pages
Deploy to Cloudflare Pages
Examples
Explore static export examples