Lightweight Next.js boilerplate optimized for Bun. It demonstrates static export (SSG) today and documents how to switch the same app to a standalone server build when you need server features.
- Bun 1.1+ (
bun --version) - Node.js optional (only needed if you prefer
nodeto run the standalone server)
bun-next-static/— Example Next.js App Router project configured for static export (output: "export"). Includes an MDX blog, simple components, and Bun-friendly scripts.
- Install deps
cd bun-next-staticbun install
- Develop
bun run dev→ http://localhost:3000 (Turbopack)
- Build static site
bun run build→ exports toout/
- Preview the export
bun run serve→ serves theout/folder locally
- Deploy
- Upload the
out/directory to any static host (GitHub Pages, Netlify, S3, Cloudflare Pages, etc.)
- Upload the
Scripts (inside bun-next-static):
dev— Next dev with Turbopackbuild— Production build; whenoutput: "export"it emits static files toout/serve—bunx serve outto preview the exported sitestart— Next server mode (not used for static hosting, but useful if you switch to server/standalone)lint— ESLint
- Static export:
out/(pure static files; no server needed) - Next build cache:
.next/(transient)
You can convert the same app to a minimal server build for environments where SSR/Route Handlers or dynamic data is required.
- Update Next config
- In
bun-next-static/next.config.ts, change:output: "export"→output: "standalone"
- In
- Build the app
bun run build
- Collect deployable artifacts
- Copy
.next/standalone/and.next/static/and thepublic/directory to your server image or host
- Copy
- Run the server
- With Bun:
bun .next/standalone/server.js - With Node:
node .next/standalone/server.js
- With Bun:
- Configure the port
- Respect standard Next.js env:
PORT=3000,HOSTNAME=0.0.0.0(set as needed)
- Respect standard Next.js env:
Notes:
- Static export removes server runtime; avoid server-only APIs. Use
generateStaticParams,fetchwithcacheoptions, andNEXT_PUBLIC_*env for client exposure. - Standalone keeps server features but ships a minimal runtime (faster cold starts and smaller deployments than full
next start).
The bun-next-static app ships with:
- MDX posts with YAML frontmatter (title, date, excerpt)
- Custom MDX element mappings (
mdx-components.tsx) - App Router routes for a blog index and post pages
Open bun-next-static/README.md for project-specific details and examples.
- Using
output: "export"and seeing missing data? Ensure pages are pre-renderable during build (no server-only code paths) and usegenerateStaticParamsfor dynamic segments. - Image optimization with
next/imagerequires a server. For pure static hosting, setunoptimizedon the Next Image component or use static<img />. - If your host doesn’t support Bun, you can still develop/build with Bun and run the standalone server with Node.
No license specified. Add one if you plan to distribute.