Skip to content

The Lighthouse field guide

From a fresh folder
to your first feature.

Choose your starting setup, run the working example, then build something of your own.

  1. 01 Create your app
  2. 02 Run it locally
  3. 03 Try your app

A working app on your machine

Get running

Have Node.js 22.12 or newer installed. The creator asks what you want to include and installs the matching packages. If you include local PostgreSQL, open Docker Desktop first; Lighthouse starts the database and applies its migrations for you.

Create your application

Open a terminal in the folder where you keep projects. Run the command below without a name or extra flags to open the setup wizard.

Run in your terminal
npm create lighthouse@latest
What is your project called? [my-app]:
Add a database with Drizzle + PostgreSQL? (y/n, Enter for yes):
Add sign-in with Better Auth? (y/n, Enter for yes):
Add interactive demos? (y/n, Enter for no):
Local port [3000]:

Type y or n, or press Enter to keep the displayed default. Next.js, TypeScript, Tailwind, Elysia + Eden, TanStack Query, and Zod are always included. You can skip the database or sign-in and add your own integration later.

Better Auth uses Drizzle and PostgreSQL. If you skip the database, sign-in defaults to no too. Choosing yes for Better Auth adds both. The demos question appears when auth is included; skipping demos still gives you the Lighthouse welcome and working example.

With the defaults, your app gets its own local database and configuration. No cloud account is needed for local development.

Start the development server

When setup finishes, enter your new folder. Replace my-app with the name you chose.

cd my-app
npm run dev

Leave that terminal running and open localhost:3000 in your browser, or use the port you chose during setup. The terminal prints the local address. Your Lighthouse welcome shows your tools, a working example, and where to start editing.

Something stopped during setup?

If the app folder was created, open a terminal inside it. Follow the recovery command printed by the creator, or use the matching step below.

Check prerequisites
npm run doctor
Finish a failed or skipped install
npm run install:deps
Regenerate missing local settings
npm run setup
Start local PostgreSQL and apply migrations
npm run setup:db
Restart an already configured local database
npm run db:up

Database commands apply only when you included PostgreSQL. Open Docker Desktop before retrying database setup. If the database port is busy, change LIGHTHOUSE_DB_PORT and the port in DATABASE_URL together in .env.local, then run npm run setup:db. The generated app includes the full guide in docs/local-development.md.

Already have PostgreSQL, or working offline?

Keep the database integration and add --skip-db to connect your own PostgreSQL service instead of starting Docker:

npm create lighthouse@latest -- --skip-db

Set the new app's DATABASE_URL in .env.local, then run npm run db:migrate inside its folder. To leave the database integration out altogether, answer n to the database and sign-in questions. For offline file generation, use --no-install; run npm run install:deps when you reconnect, followed by npm run setup:db for the default local database.

03 / See the pieces work together

Try your app

With sign-in: save your first project

In your local app, create an account. Give a project a name, add an optional description, and choose Create project. Refresh the page: the project stays in your workspace because it is saved in your local PostgreSQL database.

Sign out and back in with the same account to find it again. Projects belong to the account that created them; another account gets its own workspace.

Without sign-in: make your first API request

Enter a name in the welcome page's working example and submit it. Elysia receives the request, Zod validates it, and TanStack Query brings the response back to the interface. This example does not save personal data or require an account.

Your app's /docs page points to the exact files behind the example and the next steps for your chosen setup.

Start with one live request, then follow a complete feature

Want to try the app you're viewing?

This link stays on this Lighthouse instance. If you're viewing a hosted demo, its accounts and projects are separate from the app you run on localhost.

Try this workspace

Understand the path

One application, clear boundaries

Next.js serves the interface and mounts Elysia at /api. In the complete stack, Better Auth manages accounts and database sessions. Project routes validate input with Zod, then call shared services that enforce ownership and query PostgreSQL through Drizzle.

Browser form
  → TanStack Query + Eden
  → Elysia route + session + Zod
  → project service
  → Drizzle → PostgreSQL

Server Component
  → session + project service
  → Drizzle → PostgreSQL

The browser uses Eden with Elysia's exported API type. Server Components call the same services directly, avoiding an HTTP round trip back to the application. Elysia runs on Node.js here, with familiar routes and middleware.

Keep changes in step

Give every kind of state a home

Next.js App Router handles pages and navigation. TanStack Query handles interactive server data: fetching, loading and error states, refreshes, and mutation reconciliation. The dashboard arrives server-rendered with a hydrated cache, so the first view does not wait for another browser request.

Server data
TanStack Query
Accounts and sessions
Better Auth
Local interactions
React state
Shareable filters
The URL
const client = useQueryClient();
const projects = useQuery(projectListOptions(userId));
const create = useMutation(
  createProjectOptions(userId, client),
);

Follow src/features/projects/queries.ts for typed keys and mutation options. docs/state-management.md explains request-local caches, cancellation, retry rules, and clearing private data when accounts change. Add Zustand only when a feature needs shared client-only state; it is not installed by default.

Make the next thing yours

Build your first feature

Use your generated app's docs/first-feature.md and docs/project-structure.md to follow the example that matches your setup. With the complete stack, the path is:

  1. 01
    Add a table in src/server/db/schema.ts.
  2. 02
    Run npm run db:generate, review the SQL, then run npm run db:migrate.
  3. 03
    Create a feature schema and server service in src/features/. Keep ownership checks in the service.
  4. 04
    Add an Elysia route, call it through src/lib/api-client.ts, and define reusable Query options.
  5. 05
    Build the interface with src/components/ui/. Server Components call your service directly.

Better Auth includes email/password authentication when selected. Verification mail, password recovery, passkeys, organizations, and billing need your application decisions and the relevant configuration or integration. Add them when your product needs them.

Keep the foundation clear

A guide for every feature

Every generated app includes docs/engineering.md: technology responsibilities, practical SOLID principles, validation, permissions, accessible UI, migrations, and release checks. AGENTS.md carries those conventions into work with coding agents.

docs/development-workflow.md connects implementation, learning, and review: define one outcome, build and test a small change, explain what happened, then review behavior and engineering standards against the same source. Use the examples to practice; keep the process proportional to the work.

Keep feature rules in services, share validated contracts, and introduce abstractions when a real requirement calls for them. Before handing off a change, run:

npm run check

Auth, data, and UI changes also need the real database and browser tests. The engineering guide documents the disposable database setup. Tests skipped for missing database settings do not establish readiness. The included GitHub workflow runs those checks with PostgreSQL.

Take it beyond localhost

Deploy your application

Choose a Node.js host that supports Next.js, or package the standalone build. If you included PostgreSQL, configure a production DATABASE_URL. With Better Auth, also set a fresh BETTER_AUTH_SECRET and your exact HTTPS origin as BETTER_AUTH_URL.

If your app has a database, apply reviewed migrations once with npm run db:migrate as a controlled release step. Then build and start the app with production settings:

npm run build
npm start

Test the features you included on the deployed app. For the complete stack, check account creation, sign-in, and saving a project. Size database connection pools for the number of instances and set up backups when using persistence. The generated README and engineering guide cover configuration and release checks for your setup.

Back to Lighthouse