Ready to Start Learning?

Sign in to check if you already have access, or get started with a purchase or membership.

Tiny URL with Next.js

0:00
8/14/2023
Learn the fundamentals of the popular React.js framework Next.js by building a end-to-end URL shortening service.
Every brand should have a URL shortening service for a few reasons:
  • Data ownership
  • Analytics tracking
  • Branding (e.g. no Bitly or other services)
  • Cost Savings
URL shortening is the process of taking any URL and assigning a unique ID to it. This ID is often 2-8 letters and numbers to make the url short and consice such as jref.io/abc13 or jref.io/ad32Wa and so on.
This course will take you through each step of the way to help you build your own URL shortening service will introducing you to the speed of Next.js. deploying on Vercel, and leveraging serverless PostgresSQL with Neon.
Here's what we'll cover:
  • React.js frontend and server-side rendering ➡️ Next.js is a React.js framework that handles front-end and backend
  • Vercel for Deployment ➡️ modern and easy deployments direct from GitHub/Bitbucket
  • Neon is Modern Serverless PostgreSQL ➡️ a fast Vercel-ready Edge-ready database with sub 40ms queries!
  • Edge functions for speed/performance ➡️ Server-side components that are fast and serverless!
  • DrizzleORM for handling SQL with JavaScript ➡️ Writing SQL can be tricky; Drizzle makes it easier
  • URL Shortening ➡️ A practical way to share and track links (this is what we build)
  • Tailwind CSS & Flowbite for the User Interface ➡️ Easily one of the best ways to style frontends
  • Users and sessions with custom built login, password hashing, registration, encrypted JWT sessions and more.

Resources

If you're interested in a Django version (albeit a bit older), consider watching this course.
Tiny URL with Next.js

Lifetime access to this course

or get access to 500+ courses with a membership

Sections

1

Welcome

0:00

2

Walkthrough

0:00

3

Requirements

0:00

4

Start a Nextjs App

0:00

5

URL Routing in Nextjs

0:00

6

Handling API Routes and HTTP Methods

0:00

7

Dynamic URL Routes

0:00

8

Fetch data via Nextjs

0:00

9

Handling Fetch Errors in Nextjs

0:00

10

Pushing to Github with Git

0:00

11

Your First Nextjs Deploy to Vercel

0:00

12

Environment Variables for Vercel Domains

0:00

13

Fetch and Caching in Server Componets

0:00

14

Render React Client Component in Server Component

0:00

15

Client Side Fetching with swr

0:00

16

HTML Forms and Post Data Requests

0:00

17

Handling POST Data in a Nextjs Route

0:00

18

Validate Submitted URL For Shortening

0:00

19

Hello World from Neon Serverless

0:00

20

Edge Functions for Neon Database Connection

0:00

21

Create a SQL Table in the Neon Console

0:00

22

Your First Drizzle Table Schema

0:00

23

Create SQL from JavaScript with Drizzle

0:00

24

Create Data with Drizzle and Neon

0:00

25

Get Lists of Data with Drizzle and Neon

0:00

26

Refreshing Table Data as a Client Component

0:00

27

Refreshing Table based on Form Event

0:00

28

Storing Random Short Strings

0:00

29

Short Value DB Lookup

0:00

30

Customize the Nextjs 404 Page

0:00

31

Redirect to the Destination URL

0:00

32

Ensure Unique URLs with a SQL Index

0:00

33

Handling Database-level Errors with Unique Values

0:00

34

Visits Tracking Related Table

0:00

35

Track and Store Visits

0:00

36

Database Lookups with Related Data

0:00

37

Encypted JWT for Session Data

0:00

38

Using Cookies with Encoded JWTs

0:00

39

Adding the Users Table

0:00

40

Password Field & Hashing Functions

0:00

41

Register & Login Pages

0:00

42

Register and Save New Users in the Database

0:00

43

Login Users and Set User Session

0:00

44

List User-only Data

0:00

45

Logout Users

0:00

46

Fixing Node.js Crypto Issues for Vercel Deployment

0:00

47

Flowbite Integration & Form Alerts

0:00

48

Improved UI with Flowbite-React

0:00

49

Custom Domain Name on Vercel

0:00

50

Thank you and next steps

0:00