Skip to main content
You can run your own instance of Shorturlx. This guide covers everything you need to clone the repository, configure your environment, and deploy.

Prerequisites

Before you start, make sure you have:
  • Node.js v18 or laternodejs.org
  • PostgreSQL — any hosted or self-managed PostgreSQL database works.
  • Redis — Upstash is recommended because it provides a serverless Redis instance with a REST API that works on edge runtimes. Create a free database at upstash.com.
  • Google OAuth credentials — required for Google sign-in. Create a project at console.cloud.google.com and generate a client ID and secret.
  • GitHub OAuth credentials — optional, but enables GitHub sign-in. Create an OAuth app at github.com/settings/developers.

Setup

1

Clone the repository

git clone https://github.com/Mrdxtr/urlshortner.git
cd urlshortner
2

Install dependencies

npm install
3

Configure environment variables

Copy the example environment file and fill in your values:
cp .env.example .env
Open .env and set the following variables:
# Authentication secret — generate with: npx auth secret
AUTH_SECRET="your-secret-here"

# Google OAuth
AUTH_GOOGLE_ID="your-google-client-id"
AUTH_GOOGLE_SECRET="your-google-client-secret"

# GitHub OAuth (optional)
AUTH_GITHUB_ID="your-github-client-id"
AUTH_GITHUB_SECRET="your-github-client-secret"

# PostgreSQL connection string
DATABASE_URL="postgresql://username:password@localhost:5432/shorturlx"

# Upstash Redis
UPSTASH_REDIS_REST_URL="https://your-instance.upstash.io"
UPSTASH_REDIS_REST_TOKEN="your-upstash-token"
Never commit your .env file to version control. Keep AUTH_SECRET, database credentials, OAuth secrets, and Redis tokens out of any public repository. Use your deployment platform’s secret management to inject these values in production.
VariableRequiredDescription
AUTH_SECRETYes (production)Random secret used to sign session tokens. Generate with npx auth secret.
AUTH_GOOGLE_IDYesGoogle OAuth client ID.
AUTH_GOOGLE_SECRETYesGoogle OAuth client secret.
AUTH_GITHUB_IDNoGitHub OAuth app client ID.
AUTH_GITHUB_SECRETNoGitHub OAuth app client secret.
DATABASE_URLYesPostgreSQL connection URL.
UPSTASH_REDIS_REST_URLYesUpstash Redis REST endpoint URL.
UPSTASH_REDIS_REST_TOKENYesUpstash Redis REST token.
4

Run database migrations

Apply the Prisma schema to your database:
npx prisma migrate deploy
For a fresh development setup you can also use:
npx prisma migrate dev
5

Start the server

npm run dev
The app is available at http://localhost:3000.

Deployment options

Vercel is the simplest deployment target for Next.js applications.
  1. Push your repository to GitHub.
  2. Import the project at vercel.com/new.
  3. Add all environment variables from your .env file in the Vercel project settings under Environment Variables.
  4. Deploy. Vercel handles builds and edge delivery automatically.
Make sure your PostgreSQL database is accessible from Vercel’s deployment region. Managed services like Supabase, Neon, or Railway work well. A local PostgreSQL instance is not reachable from Vercel.

Netlify

  1. Push your repository to GitHub.
  2. Create a new site at app.netlify.com and connect your repository.
  3. Set the build command to npm run build and the publish directory to .next.
  4. Add all environment variables in the Netlify site settings under Environment variables.
  5. Deploy.

Docker

You can build and run Shorturlx in a container. Set SKIP_ENV_VALIDATION=1 during the build step to skip environment validation, then supply the real variables at runtime.
# Build the image
docker build -t shorturlx .

# Run the container
docker run -p 3000:3000 \
  -e AUTH_SECRET="your-secret" \
  -e AUTH_GOOGLE_ID="your-google-id" \
  -e AUTH_GOOGLE_SECRET="your-google-secret" \
  -e DATABASE_URL="postgresql://..." \
  -e UPSTASH_REDIS_REST_URL="https://..." \
  -e UPSTASH_REDIS_REST_TOKEN="your-token" \
  shorturlx
Use Docker secrets or an environment file (--env-file .env) rather than passing secrets directly on the command line in production.

Build docs developers (and LLMs) love