Docs/getting started/Installation

Installation

This guide will help you set up NextShip on your local machine.

Prerequisites

Before you begin, make sure you have:

  • Node.js 18.17+ - Download
  • pnpm 9+ - Install with npm install -g pnpm
  • PostgreSQL database - We recommend Neon (free tier available)

Clone the Repository

git clone https://github.com/your-username/nextship.git my-saas
cd my-saas

Install Dependencies

pnpm install

Environment Setup

Copy the example environment file:

cp .env.example .env.local

Required Variables

# App
NEXT_PUBLIC_APP_URL=http://localhost:4000
 
# Database (Neon PostgreSQL)
DATABASE_URL=postgresql://user:pass@host/db?sslmode=require
 
# Auth (Better Auth)
BETTER_AUTH_SECRET=your-random-secret-key-min-32-chars

Optional Variables

# OAuth Providers
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
 
# Payments - Stripe (default)
PAYMENT_PROVIDER=stripe
STRIPE_SECRET_KEY=sk_test_xxx
STRIPE_WEBHOOK_SECRET=whsec_xxx
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_xxx
 
# Payments - Creem (alternative)
# PAYMENT_PROVIDER=creem
# CREEM_API_KEY=ck_test_xxx
# CREEM_WEBHOOK_SECRET=xxx
 
# Email (Resend)
RESEND_API_KEY=re_xxx
EMAIL_FROM=noreply@yourdomain.com
 
# File Storage (Cloudflare R2 or AWS S3)
R2_ACCOUNT_ID=
R2_ACCESS_KEY_ID=
R2_SECRET_ACCESS_KEY=
R2_BUCKET_NAME=
R2_PUBLIC_URL=
 
# AI Gateway (optional)
OPENAI_API_KEY=sk-xxx
ANTHROPIC_API_KEY=sk-ant-xxx

Database Setup

Push the database schema to create tables:

pnpm db:push

To view and manage your database:

pnpm db:studio

Start Development Server

pnpm dev

Your app is now running at http://localhost:4000!

Stripe Webhooks (Local Development)

To test payments locally:

# Install Stripe CLI (macOS)
brew install stripe/stripe-cli/stripe
 
# Login to Stripe
stripe login
 
# Forward webhooks to local server
pnpm stripe:listen

Email Templates (Development)

Preview email templates:

pnpm email:dev

Opens at http://localhost:3001

Scripts Reference

CommandDescription
pnpm devStart dev server (port 4000)
pnpm buildProduction build
pnpm startStart production server
pnpm db:pushPush schema changes
pnpm db:studioOpen Drizzle Studio
pnpm db:generateGenerate migrations
pnpm db:migrateRun migrations
pnpm stripe:listenForward Stripe webhooks
pnpm email:devPreview email templates
pnpm check:fixFix lint issues

Next Steps