Skip to main content
Prisma Documentation Docs

Search documentation

Type to search this documentation.

On this pageOverview

Linktree Clone SaaS

In this vibe coding tutorial, you'll build a Linktree clone SaaS application from scratch with an AI coding assistant. The stack is:

By the end of this tutorial, you'll have a working SaaS application where users can sign up, create their profile, and manage their personal link page, all built with AI-assisted development.

Watch this step-by-step walkthrough of the entire build process:

https://www.youtube.com/embed/R3GJ1eo943k

Before starting this tutorial, make sure you have:

Create a new Next.js application:

title="bun"
bunx create-next-app@latest app-name
pnpm
pnpm dlx create-next-app@latest app-name
yarn
yarn dlx create-next-app@latest app-name
npm
npx create-next-app@latest app-name

Once the setup is complete, add Prisma and Prisma Postgres to your project with the prepared setup prompt.

👉 Find the setup prompt here: Next.js + Prisma Prompt

How to use it:

  1. Create a new file called prompt.md at the root of your project
  2. Copy and paste the prompt content into this file
  3. Ask your AI assistant to follow the instructions in this file

The AI sets up Prisma ORM, creates your database connection, and configures the project.

Verify the setup:

  1. Start your development server:

    bun run dev
    Bash
    pnpm run dev
    Bash
    yarn dev
    Bash
    npm run dev
    1. Open Prisma Studio to view your seed data:
  2. Open Prisma Studio to view your seed data:

    title="bun"
    bun run db:studio
    pnpm
    pnpm run db:studio
    yarn
    yarn db:studio
    npm
    npm run db:studio

If both commands run without errors and you can see sample data in Prisma Studio, you're ready to continue.

Add user authentication with Clerk, which provides sign-up, sign-in, and session management.

Steps to follow:

  1. Go to Clerk and create an account (if you don't have one)
  2. Create a new application in your Clerk dashboard
  3. Follow Clerk's official quickstart guide to integrate it with your Next.js app:

👉 Clerk Next.js Quickstart: clerk.com/docs/nextjs/getting-started/quickstart

The guide will walk you through installing the SDK, adding environment variables, and wrapping your app with the ClerkProvider.

Once complete, commit your changes:

git add .

git commit -m "Add Clerk authentication setup"

Since we're building a Linktree clone, we need to update the database schema to support our specific data model. This includes:

  • A User model with a unique username (for public profile URLs like /username)
  • A Link model to store each user's links

Replace the contents of your prisma/schema.prisma file with the following:

title="prisma/schema.prisma"
generator client {

  provider = "prisma-client"

  output   = "../app/generated/prisma"

}

datasource db {

  provider = "postgresql"

}

// Example User model for testing

model User {

  id        Int      @id @default(autoincrement())

  email     String   @unique

  username  String   @unique // Important for the public profile URL

  clerkId   String   @unique // Links to Clerk Auth

  name      String?

  links     Link[]

  createdAt DateTime @default(now())

  updatedAt DateTime @updatedAt

}

model Link {

  id        Int      @id @default(autoincrement())

  title     String

  url       String

  userId    Int

  user      User     @relation(fields: [userId], references: [id])

  createdAt DateTime @default(now())

}

Since we're changing the schema structure, we need to reset the database. The existing seed data was just for testing purposes, so it's safe to drop and recreate:

title="bun"
bunx prisma db push --force-reset
pnpm
pnpm prisma db push --force-reset
yarn
yarn prisma db push --force-reset
npm
npx prisma db push --force-reset

This command:

  • Drops the existing database tables
  • Creates new tables based on your updated schema

Open Prisma Studio to verify the new schema is applied:

title="bun"
bun run db:studio
pnpm
pnpm run db:studio
yarn
yarn db:studio
npm
npm run db:studio

You should see the updated User and Link tables (they'll be empty, which is expected).

Commit your changes:

git add .

git commit -m "Update schema for Linktree clone"

When a user signs in with Clerk, they exist in Clerk's system but not in your database. To bridge this gap, create a "Claim Username" flow where users pick their unique username (e.g., yourapp.com/johndoe) after signing in for the first time.

Copy and paste the following prompt into your AI assistant:

Connect Clerk authentication to your Prisma database with a "Claim Username" flow.

**Goal:**

When a user signs in via Clerk, they don't automatically exist in YOUR database. Create a flow where:

1. Logged out → Show landing page with "Sign In" button

2. Logged in but no DB profile → Show "Claim Username" form

3. Has DB profile → Show dashboard

**User Model (already in schema):**

model User {

id Int @id @default(autoincrement())

email String @unique

username String @unique

clerkId String @unique

name String?

links Link[]

createdAt DateTime @default(now())

updatedAt DateTime @updatedAt

}

**Files to create/update:**

1. `app/actions.ts` - Server Action with `claimUsername(formData)`

2. `app/page.tsx` - Three-state UI (logged out / claim username / dashboard)

3. `app/api/users/route.ts` - Update POST to accept `clerkId`, `email`, `username`, `name`

**Requirements:**

- Use `'use server'` directive in `app/actions.ts`

- Use `currentUser()` from `@clerk/nextjs/server` to get auth user

- Store `clerkId`, `email`, `username`, and `name` in User model

- Use `redirect("/")` after successful profile creation

- Handle username uniqueness (Prisma will throw if duplicate)

**Pattern:**

1. Server Action receives FormData, validates username (min 3 chars, alphanumeric + underscore)

2. Creates User in Prisma with Clerk's `user.id` as `clerkId`

3. Page.tsx checks: `currentUser()` → then `prisma.user.findUnique({ where: { clerkId } })`

4. Render different UI based on auth state and DB state

**Keep it simple:**

- No middleware file needed

- No webhook sync (user creates profile manually)

- Basic validation (username length >= 3)

- Errors just throw (no fancy error UI for MVP)

After the AI generates the code, you may see TypeScript errors. This is because the Prisma Client needs to be regenerated to reflect the schema changes:

title="bun"
bunx prisma generate
pnpm
pnpm prisma generate
yarn
yarn prisma generate
npm
npx prisma generate

Test the complete flow:

  1. Stop your dev server and restart it
  2. Open your app in the browser
  3. Sign up as a new user through Clerk
  4. You should see the "Claim Username" form
  5. Enter a username and submit
  6. Verify the user appears in Prisma Studio (npm run db:studio)

If everything works, commit your changes.

Give the app a cleaner, friendlier look inspired by platforms like Buy Me a Coffee.

👉 Visit Buy Me a Coffee for design inspiration

Copy and paste this prompt to your AI assistant:

Design a minimal, friendly UI inspired by Buy Me a Coffee.

**Theme:**

- Force light mode only (no dark mode switching)

- Clean white background (#FFFFFF)

- Black text (#000000) for headings

- Gray (#6B7280) for secondary text

- Bright yellow (#FFDD00) for CTA buttons

- Light gray (#F7F7F7) for cards/sections

- Subtle borders (#E5E5E5)

**Typography & Spacing:**

- Large, bold headlines (text-5xl or bigger)

- Generous whitespace and padding

- Rounded corners everywhere (rounded-full for buttons, rounded-xl for cards)

**Buttons:**

- Primary: Yellow background, black text, rounded-full, font-semibold

- Secondary: White background, border, rounded-full

**Overall feel:**

- Friendly, approachable, not corporate

- Minimal — only essential elements

- Mobile-first with good touch targets (py-4, px-8 on buttons)

- One unified canvas — background applies to the entire page (body), with white cards floating on top. No separate section backgrounds.

Use Tailwind CSS. Keep it simple.

After the AI applies the changes:

  1. Refresh your app and browse through all pages
  2. Verify the design has updated but no functionality has changed
  3. Test the sign-in flow and username claim process

Once verified, commit the changes:

git add .

git commit -m "Update UI design"

Add the core functionality, managing links. Users should be able to add new links and delete existing ones from their dashboard.

Copy and paste this prompt:

Build a simple dashboard for managing links using Next.js App Router and Server Actions.

**Requirements:**

- Server Component page that fetches user data from database

- "Add Link" form with Title and URL inputs

- List of existing links with Delete button

- Use Server Actions (no API routes) for create/delete operations

- Use `revalidatePath("/")` after mutations to refresh the page

**Pattern:**

1. Create server actions in `actions.ts` with `'use server'` directive

2. Pass actions directly to form `action` prop

3. Keep page.tsx as a Server Component (no 'use client')

4. Use hidden inputs for IDs (e.g., `<input type="hidden" name="linkId" value={id} />`)

**Keep it simple:**

- No loading states

- No client components

- No confirmation dialogs

- Just forms + server actions + revalidation

This is the MVP pattern for CRUD with Next.js App Router.

Test the link management:

  1. Add a new link with a title and URL
  2. Verify it appears in your dashboard
  3. Delete the link
  4. Verify it's removed

Both operations should work instantly without page navigation.

This is the heart of a Linktree clone: public profile pages that anyone can visit at /username.

Copy and paste this prompt:

Build a public profile page at /[username] using Next.js App Router dynamic routes.

**Requirements:**

- Create `app/[username]/page.tsx` as a Server Component

- Fetch user + links from database by username (from URL params)

- Return 404 if user not found (use `notFound()` from next/navigation)

- Display: avatar (first letter), username, name, and list of links

- Links open in new tab with `target="_blank"`

- Add a small "Create your own" link at the bottom

**Pattern:**

1. Get params: `const { username } = await params`

2. Query database with `findUnique({ where: { username } })`

3. If no user: call `notFound()`

4. Render profile with links as clickable buttons

**Keep it simple:**

- No auth required (it's a public page)

- Pure Server Component (no 'use client')

- Basic styling with hover effects

This is the core "Linktree" feature — anyone can visit /username to see the links.

Test your public profile:

  1. Navigate to localhost:3000/your-username (replace with your actual username)
  2. Verify your profile and links display correctly
  3. Click a link and confirm it opens in a new tab

Make it easy for users to share their profile URL with a one-click copy button.

Copy and paste this prompt:

**Requirements:**

- Create a Client Component (`'use client'`) for the button

- Use `navigator.clipboard.writeText(url)` to copy

- Show "Copied!" feedback for 2 seconds after clicking

- Use `useState` to toggle the button text

**Pattern:**

1. Create `app/components/copy-button.tsx` with 'use client'

2. Accept `url` as a prop

3. On click: copy to clipboard, set `copied` to true

4. Use `setTimeout` to reset after 2 seconds

5. Import and use in your Server Component page

**Keep it simple:**

- One small client component

- No toast libraries

- Just inline text feedback ("Copy link" → "Copied!")
  1. Find the "Copy link" button on your dashboard
  2. Click it and verify it shows "Copied!"
  3. Paste somewhere to confirm the URL was copied correctly

When someone visits a non-existent username, they should see a friendly error page instead of a generic 404.

Copy and paste this prompt:

Create a custom 404 page for Next.js App Router.

**Requirements:**

- Create `app/not-found.tsx` (Server Component)

- Display: 404 heading, friendly message, "Go home" button

- Match your app's design (colors, fonts, spacing)

**Pattern:**

- Next.js automatically uses `not-found.tsx` when `notFound()` is called

- Or when a route doesn't exist

- No configuration needed — just create the file

**Keep it simple:**

- Static page, no data fetching

- One heading, one message, one link

- Same styling as rest of the app

Test the 404 page by visiting a random URL like /this-user-does-not-exist. You should see your custom 404 page with a link back to the homepage.

Add a custom background pattern to the app.

First, either:

Then, save it as background.svg in your public/ folder.

Copy and paste this prompt:

Add a custom SVG background to my app.

**Requirements:**

- The svg file is in the `public/` folder (e.g., `public/background.svg`)

- Apply it as a fixed, full-cover background on the body

**Pattern:**

In `globals.css`, update the body:

```css

body {

  background: var(--background) url("/background.svg") center/cover no-repeat fixed;

  min-height: 100vh;

}

```

**Key properties:**

- `center/cover` — centers and scales to fill

- `no-repeat` — prevents tiling

- `fixed` — background stays in place when scrolling

Files in `public/` are served at the root URL, so `/background.svg` works.
  1. Refresh your app
  2. Verify the background appears on all pages (homepage, dashboard, profile pages, 404)
  3. If the background doesn't appear everywhere, ask your AI to fix it

Commit your changes once it's working correctly.

Create visual depth by adding semi-transparent card containers that "float" over the background.

Copy and paste this prompt:

Add a reusable card container class to create visual separation from the background.

**Requirements:**

- Create a `.card` class in `globals.css`

- Apply glassmorphism: semi-transparent white + blur

- Use on all main content areas (landing, forms, dashboard, profile pages)

**Pattern:**

In `globals.css`, add:

```css

.card {

  background: rgba(255, 255, 255, 0.9);

  backdrop-filter: blur(10px);

  border-radius: 1.5rem;

  padding: 2rem;

  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);

}

```

**Usage:**

Wrap content sections with `<div className="card">...</div>`

For public profile pages (/[username]):

Wrap the entire profile (avatar, name, username, and links list) in a single .card container

This creates a Linktree-style floating card effect

Footer/attribution links stay outside the card

Hero section:

Add a soft radial glow behind the content (large blurred white circle, blur-3xl, 50% opacity)

No visible container edges — just organic, fading brightness

Content floats freely over the glow

**Result:**

- Content "lifts" off the background

- Subtle blur creates depth

- Consistent UI across all pages

If users sign in with Google or another OAuth provider, Clerk stores their profile photo. Display it on public profiles.

Copy and paste this prompt:

On the public profile page (`/[username]`), display the user's Clerk profile image (Google photo, etc.) instead of the initial letter avatar.

**Pattern:**

```typescript

// Fetch Clerk user to get profile image

const client = await clerkClient();

const clerkUser = await client.users.getUser(user.clerkId);

```

**Display:**

- Use a plain `<img>` tag (not Next.js Image component)

- If `clerkUser.imageUrl` exists, show the image

- Otherwise fallback to the yellow initial avatar

**Keep it simple:**

- No try/catch — let errors bubble up

- No next.config changes needed

- No database schema changes needed

Visit your public profile page and verify your profile image (from Google, GitHub, etc.) is displayed instead of the initial letter avatar.

Add icons with Lucide React to make buttons and empty states easier to read.

Copy and paste this prompt:

Add Lucide React icons to improve the UI.

First install: npm install lucide-react

Add icons to these elements:

- View button: ExternalLink icon

- Delete button: Trash2 icon (replace text with icon)

- Empty links state: Link icon

Import icons from 'lucide-react' and use with size prop (e.g., size={18}).

Keep buttons minimal — only add icons where they improve clarity.

Browse through your app and verify the icons appear on:

  • The view/external link buttons
  • The delete buttons
  • The empty state when no links exist

Deploy your app to Vercel.

Add a postinstall script to ensure Prisma Client is generated during deployment.

Add this to your package.json scripts section:

title="package.json"
{

  "scripts": {

    "postinstall": "prisma generate"

  }

}

📖 Reference: Deploy to Vercel - Build Configuration

Delete the scripts/ folder if it exists. This folder was auto-generated during initial setup for seed data, you don't need it in production.

  1. Push your code to GitHub (if you haven't already)

  2. Go to vercel.com and import your repository

  3. Important: Add all your environment variables in Vercel's dashboard:

    • DATABASE_URL
    • NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
    • CLERK_SECRET_KEY

After your first deployment:

  1. Copy your production URL from Vercel (e.g., https://your-app.vercel.app)

  2. Add a new environment variable in Vercel:

    NEXT_PUBLIC_APP_URL=https://your-app.vercel.app
  3. Redeploy to apply the change

Test your deployed app thoroughly:

  • Sign up flow works
  • Username claiming works
  • Adding/deleting links works
  • Public profile pages load correctly
  • Copy link copies the correct production URL
  • 404 page displays for non-existent usernames

Your Linktree clone is live.

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu