Redirect.link is a URL shortener that shortens URL to rdt.li/slug and also tracks number of visits. It is built with Next.js, Drizzle, NextAuth and Postgres.
Features · Roadmap · Author · Credits
Made via Onset a Next.js starter that comes with step-by-step instructions to understand how everything works, easy for both beginners and experts alike and giving you the confidence to customize it to your needs. Built with Next.js 14, Drizzle (Postgres), NextAuth/Auth.js.
- Next.js – React framework for building performant apps with the best developer experience
- Auth.js – Handle user authentication with ease with providers like Google, Twitter, GitHub, etc.
- Drizzle – Typescript-first ORM for Node.js
- Vercel – Easily preview & deploy changes with git
- Neon – The fully managed serverless Postgres with a generous free tier
Clone & create this repo locally with the following command:
Note: You can use
npx
orpnpx
as well
bunx create-next-app onset-starter --example "https://github.com/nrjdalal/onset"
- Install dependencies using pnpm:
bun install
- Copy
.env.example
to.env.local
and update the variables.
cp .env.example .env.local
- Run the database migrations:
bun db:push
- Start the development server:
bun dev
- Get your Google OAuth credentials at https://console.cloud.google.com/ into your .env
Make sure to add
https://your_url
to "Authorised JavaScript origins" andhttps://your_url/api/auth/callback/google
to Authorised redirect URIs - Set
your_url
asNEXT_PUBLIC_CUSTOM_DOMAIN
in your .env - Set up Neon account and copy postgres url including
?sslmode=require
into your .env - Set up your tables using the SQL Editor on Neon:
CREATE TABLE "user" (
id TEXT NOT NULL PRIMARY KEY,
name TEXT,
email TEXT NOT NULL,
"emailVerified" TIMESTAMP,
image TEXT
);
CREATE TABLE account (
"userId" TEXT NOT NULL REFERENCES "user"(id) ON DELETE CASCADE,
type TEXT NOT NULL,
provider TEXT NOT NULL,
"providerAccountId" TEXT NOT NULL,
"refresh_token" TEXT,
"access_token" TEXT,
"expires_at" INTEGER,
"token_type" TEXT,
scope TEXT,
"id_token" TEXT,
"session_state" TEXT,
PRIMARY KEY (provider, "providerAccountId")
);
CREATE TABLE session (
"sessionToken" TEXT NOT NULL PRIMARY KEY,
"userId" TEXT NOT NULL REFERENCES "user"(id) ON DELETE CASCADE,
expires TIMESTAMP NOT NULL
);
CREATE TABLE "verificationToken" (
identifier TEXT NOT NULL,
token TEXT NOT NULL,
expires TIMESTAMP NOT NULL,
PRIMARY KEY (identifier, token)
);
CREATE TABLE "shortUrls" (
"userId" TEXT NOT NULL REFERENCES "user"(id) ON DELETE CASCADE,
id TEXT NOT NULL PRIMARY KEY,
url TEXT NOT NULL,
visits JSON,
"createdAt" TIMESTAMP NOT NULL,
"updatedAt" TIMESTAMP NOT NULL
);
- Deploy on Vercel
- Optional: Set up a custom url at https://vercel.com/{your_org}/{your_repo}/settings/domains and make sure to add this url to your .env and to your Google OAuth credentials
- Light and dark mode
- More features and points to be added
Created by @nrjdalal in 2023, released under the MIT license.