Skip to content

Repository files navigation

TinyApp

A tiny URL shortener built with Next.js 15, Auth.js, Drizzle ORM, and Neon Postgres, deployed on Vercel.

Features

  • 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

Local development

Prerequisites

  • Node.js 20+
  • A Neon database (free tier)

Setup

  1. Install dependencies:

    npm install
  2. Copy environment variables:

    cp .env.example .env.local
  3. Set values in .env.local:

    • DATABASE_URL — Neon connection string
    • AUTH_SECRET — run openssl rand -base64 32
    • AUTH_URLhttp://localhost:3000
  4. 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 -pooler host) in .env or .env.local. Optional: npm run db:push:drizzle uses drizzle-kit (needs WebSockets).

  5. Start the dev server:

    npm run dev

Open http://localhost:3000.

Scripts

ScriptDescription
npm run devStart Next.js dev server
npm run buildProduction build
npm run startRun production server locally
npm run lintESLint
npm testVitest unit tests
npm run db:pushApply Drizzle schema to the database
npm run db:generateGenerate SQL migrations
npm run db:migrateRun migrations

Deploy to Vercel

  1. Push this repo to GitHub.

  2. Import the project in Vercel.

  3. Add environment variables in the Vercel project settings:

    VariableValue
    DATABASE_URLNeon connection string
    AUTH_SECRETLong random secret
    AUTH_URLhttps://your-app.vercel.app
  4. Deploy. After the first deploy, run npm run db:push locally against your production Neon branch (or use Neon's SQL editor with drizzle/migrations/0000_initial.sql).

Vercel will run next build automatically on each push.

Project structure

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/*

License

ISC

About

A tiny and fun URL shortener. The user can visit the page and create minified URL's for sharing around the web. The app uses Node.js, Express.js, EJS Template Engine, and Bootstrap.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages