Prerequisites
Before you start, make sure you have:- Node.js v18 or later — nodejs.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
Configure environment variables
Copy the example environment file and fill in your values:Open
.env and set the following variables:| Variable | Required | Description |
|---|---|---|
AUTH_SECRET | Yes (production) | Random secret used to sign session tokens. Generate with npx auth secret. |
AUTH_GOOGLE_ID | Yes | Google OAuth client ID. |
AUTH_GOOGLE_SECRET | Yes | Google OAuth client secret. |
AUTH_GITHUB_ID | No | GitHub OAuth app client ID. |
AUTH_GITHUB_SECRET | No | GitHub OAuth app client secret. |
DATABASE_URL | Yes | PostgreSQL connection URL. |
UPSTASH_REDIS_REST_URL | Yes | Upstash Redis REST endpoint URL. |
UPSTASH_REDIS_REST_TOKEN | Yes | Upstash Redis REST token. |
Run database migrations
Apply the Prisma schema to your database:For a fresh development setup you can also use:
Deployment options
Vercel (recommended)
Vercel is the simplest deployment target for Next.js applications.- Push your repository to GitHub.
- Import the project at vercel.com/new.
- Add all environment variables from your
.envfile in the Vercel project settings under Environment Variables. - Deploy. Vercel handles builds and edge delivery automatically.
Netlify
- Push your repository to GitHub.
- Create a new site at app.netlify.com and connect your repository.
- Set the build command to
npm run buildand the publish directory to.next. - Add all environment variables in the Netlify site settings under Environment variables.
- Deploy.
Docker
You can build and run Shorturlx in a container. SetSKIP_ENV_VALIDATION=1 during the build step to skip environment validation, then supply the real variables at runtime.
--env-file .env) rather than passing secrets directly on the command line in production.