Documentation

Installation

This guide walks you through every step from a blank machine to a running Nestled application.


Prerequisites

Before you begin, make sure you have the following installed:

  • Node.js 20+ — Download from nodejs.org. The template uses Node 22.
  • pnpm — Install with npm install -g pnpm
  • Git — For cloning the template
  • Docker — Required for PostgreSQL, Redis, and Mailhog. Get Docker.

Why pnpm?

Nestled uses pnpm for package management. Its efficient disk usage and strict dependency resolution make it ideal for monorepos with many packages.


Clone the template

git clone https://github.com/nestledjs/nestled-template.git my-app
cd my-app

Remove the existing git history and start fresh:

rm -rf .git
git init

Configure your environment

Copy the example environment file:

cp .env.example .env

For local development, the defaults work out of the box — you just need to install dependencies first:

pnpm install

Build approvals

You may need to run pnpm approve --builds to approve libraries that require native compilation (Prisma, SWC, etc.).


Set up your workspace

Run the workspace setup generator to name your project and initialize everything:

nx g @nestledjs/generators:workspace-setup --name my-app

This does several things:

  1. Renames the workspace — finds and replaces nestled-template throughout the project with your chosen name. All your imports will use @my-app/... going forward.
  2. Starts Docker services — spins up PostgreSQL, Redis, and Mailhog
  3. Runs database migrations — pushes the Prisma schema to your database
  4. Seeds the database — creates an admin user and initial data

Choosing a name

Use lowercase with dashes for spaces (e.g., my-app, acme-saas, todo-pro). Keep it short — this becomes the @name/ prefix for every import in your project, so shorter means less typing during development.


Environment variables

The key variables you may want to customize in .env:

Core settings

VariableDefaultDescription
APP_NAMEyour-app-nameApplication name, used in emails and 2FA
PORT3000API server port
JWT_SECRETJWT_SECRETChange this — secret for signing auth tokens
API_URLhttp://localhost:3000API base URL
SITE_URLhttp://localhost:4200Frontend base URL

Database

VariableDefaultDescription
DATABASE_URLpostgresql://prisma:prisma@localhost:5432/prismaPostgreSQL connection string

Email

VariableDefaultDescription
EMAIL_PROVIDERNot set (uses SMTP)Set to mock to skip real emails in CI/testing
SMTP_HOSTlocalhostSMTP server host (Mailhog in local dev)
SMTP_PORT1025SMTP server port

Stripe billing (optional)

VariableDescription
STRIPE_SECRET_KEYYour Stripe secret key (sk_test_...)
STRIPE_PUBLISHABLE_KEYYour Stripe publishable key (pk_test_...)
STRIPE_WEBHOOK_SECRETWebhook signing secret (whsec_...)
STRIPE_CURRENCYCurrency code (default: usd)

OAuth providers (optional)

VariableDescription
GOOGLE_OAUTH_CLIENT_IDGoogle OAuth client ID
GOOGLE_OAUTH_CLIENT_SECRETGoogle OAuth client secret
GITHUB_OAUTH_CLIENT_IDGitHub OAuth client ID
GITHUB_OAUTH_CLIENT_SECRETGitHub OAuth client secret

File storage (optional)

VariableDescription
STORAGE_PROVIDERlocal, s3, cloudinary, imagekit, or gcs

Each provider has its own set of keys (AWS keys for S3, Cloudinary API key/secret, etc.). See .env.example for the full list.


Start development

Run these three commands in separate terminals:

# Terminal 1 — API server
nx serve api

# Terminal 2 — Web application
nx serve web

# Terminal 3 — SDK type generation (watches for changes)
pnpm sdk watch

Verify everything works


Your first schema change

The real power of Nestled is the code generation pipeline. Try adding a model to your schema:

  1. Edit libs/api/prisma/src/lib/schemas/schema.prisma
  2. Run pnpm db-update — regenerates your entire API, types, and SDK
  3. Run pnpm prisma db push — applies schema changes to the database
  4. Your API now has full CRUD for the new model, and your frontend has typed queries ready to use

See the Commands reference for details on every available script, or read about the Architecture to understand how all the pieces fit together.

Previous
Getting started