Skip to content

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.

License

Notifications You must be signed in to change notification settings

seichris/url-shortener

 
 

Repository files navigation

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.

Follow Neeraj on Twitter

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.

Features

Frameworks

  • 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

Platforms

  • Vercel – Easily preview & deploy changes with git
  • Neon – The fully managed serverless Postgres with a generous free tier

Local Installation

Clone & create this repo locally with the following command:

Note: You can use npx or pnpx as well

bunx create-next-app onset-starter --example "https://github.com/nrjdalal/onset"
  1. Install dependencies using pnpm:
bun install
  1. Copy .env.example to .env.local and update the variables.
cp .env.example .env.local
  1. Run the database migrations:
bun db:push
  1. Start the development server:
bun dev

Deploy on Vercel

  1. 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" and https://your_url/api/auth/callback/google to Authorised redirect URIs
  2. Set your_url as NEXT_PUBLIC_CUSTOM_DOMAIN in your .env
  3. Set up Neon account and copy postgres url including ?sslmode=require into your .env
  4. 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
);
  1. Deploy on Vercel
  2. 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

Roadmap

  • Light and dark mode
  • More features and points to be added

Author

Created by @nrjdalal in 2023, released under the MIT license.

Credits

This project is inspired by @shadcn's Taxonomy.

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 90.3%
  • JavaScript 5.9%
  • CSS 3.8%