A tiny URL shortener built with Next.js 15, Auth.js, Drizzle ORM, and Neon Postgres, deployed on Vercel.
- Register and log in with email and password
- Create, edit, and delete short URLs
- Public redirects at
/u/:shortURL - Portfolio-friendly UI preserved from the original TinyApp
- Node.js 20+
- A Neon database (free tier)
-
Install dependencies:
npm install
-
Copy environment variables:
cp .env.example .env.local
-
Set values in
.env.local:DATABASE_URL— Neon connection stringAUTH_SECRET— runopenssl rand -base64 32AUTH_URL—http://localhost:3000
-
Push the schema to your database:
npm run db:push
This runs
scripts/db-setup.mjs(node-postgres), which is reliable on Windows. Use Neon’s direct connection string (not the-poolerhost) in.envor.env.local. Optional:npm run db:push:drizzleuses drizzle-kit (needs WebSockets). -
Start the dev server:
npm run dev
Open http://localhost:3000.
| Script | Description |
|---|---|
npm run dev |
Start Next.js dev server |
npm run build |
Production build |
npm run start |
Run production server locally |
npm run lint |
ESLint |
npm test |
Vitest unit tests |
npm run db:push |
Apply Drizzle schema to the database |
npm run db:generate |
Generate SQL migrations |
npm run db:migrate |
Run migrations |
-
Push this repo to GitHub.
-
Import the project in Vercel.
-
Add environment variables in the Vercel project settings:
Variable Value DATABASE_URLNeon connection string AUTH_SECRETLong random secret AUTH_URLhttps://your-app.vercel.app -
Deploy. After the first deploy, run
npm run db:pushlocally against your production Neon branch (or use Neon's SQL editor withdrizzle/migrations/0000_initial.sql).
Vercel will run next build automatically on each push.
app/ # App Router pages and API routes
components/ # React UI components
drizzle/ # Schema and migrations
lib/ # Database helpers and auth utilities
auth.ts # Auth.js configuration
middleware.ts # Protects /urls/*
ISC