# Next.js

A Next.js 16 App Router starter in TypeScript with React 19 server components, for developers who want a clean server-rendered project to build on. It includes a shared layout, Home, About and 404 pages, a GET /api/health route handler, ESLint and Vitest.

- Framework: Next.js (JavaScript)
- Category: Starters / Full-stack
- Creates: a server app
- Plan: Free
- Price: Free
- Author: Light Cloud
- Page: https://templates.light-cloud.com/starters/fullstack/nextjs-app-router-starter
- Updated: 2026-11-21

## Features

- App Router pages: / rendered on every request with its server render time, /about, and a custom 404
- A route handler at GET /api/health that answers 200 with { status: ok }, covered by a Vitest test
- Root layout with a shared header (site name and navigation) and footer from components/
- Geist and Geist Mono through next/font, with colour tokens and a dark theme that follows the system
- ESLint 9 flat config with eslint-config-next (Core Web Vitals and TypeScript rules)
- NEXT_PUBLIC_SITE_NAME sets the site name, and next start listens on PORT (default 3000)
- An @/* import alias pointing at the project root

## What you need

- Free plan: it runs as a server app, and the Free plan includes 3 server apps
- To run it locally: Node.js 22.12 or later and npm
- No API keys: it starts with nothing to configure

## About

Pages are React server components rendered on the Node.js server, and route handlers in app/api/ answer with JSON, so one project covers both the site and a small API. The home page opts into per-request rendering with dynamic = force-dynamic to show server rendering at work; remove that line to prerender it at build time. Most people first add pages under app/ and a database or auth next. Deploying runs npm run build, then npm start in a container that listens on PORT.

## Questions

### How do I add a new page in the Next.js App Router?

Create a folder under app/ with a page.tsx in it: app/contact/page.tsx becomes /contact. Add a link to it in components/site-header.tsx.

### How do I add an API route in Next.js 16?

Create a route.ts file under app/api/ and export a function named after the HTTP method, as in app/api/health/route.ts. app/api/hello/route.ts with export function GET() answers GET /api/hello.

### Can I prerender the home page instead of rendering it on every request?

Yes. Remove export const dynamic = force-dynamic from app/page.tsx and Next.js renders it once at build time. Route handlers keep working because the app still runs on a server.

### Is there a free Next.js starter template I can deploy?

Yes. It is MIT licensed and runs as a server app, and the Light Cloud Free plan includes 3 server apps with no card needed.

### Can I host this Next.js template without Light Cloud?

Yes. It has no Light Cloud code in it: any host with Node.js 20.9 or later runs it with npm ci, npm run build and npm start.
