T3-STACK COURSE GUIDE

Build a Twitter Clone with the T3 Stack

A chapter-by-chapter readback of the free course by Theo Browne on Theo - t3․gg.

Length2:59:02
Chapters30
Modules7
Plain Markdown with clickable timestamps — drops into Obsidian, Notion or GitHub as-is.
Watch on Theo - t3․gg · chapter timestamps in the contents jump the video
Contents
  1. Project Setup, Database, and First Deploy
    1. 0:00 · Introduction
    2. 2:08 · Scaffolding with Create T3 App
    3. 4:50 · Vercel Deploy and Environment Variables
    4. 6:07 · Setting Up PlanetScale
    5. 8:48 · Prisma Workflow and First Production Deploy
  2. Authentication and Observability
    1. 11:43 · Adding Clerk Auth
    2. 16:18 · Sign-In Flow and Conditional Rendering
    3. 20:03 · Logging with Axiom
  3. Data Modeling and the First tRPC Endpoint
    1. 21:29 · The Post Model
    2. 24:10 · tRPC Routers and the Frontend/Backend Magic
    3. 28:32 · Seeding Data and Deploying the Feed
  4. Styling the Twitter Clone UI
    1. 30:33 · Global Styles and Centered Layout
    2. 34:38 · Top Navigation and Feed Structure
    3. 37:22 · Building the Create Post Wizard
  5. Merging Users into Posts
    1. 41:42 · Fetching Post Data with Prisma and Clerk
    2. 46:48 · Building Author Objects and Derived Types
    3. 52:18 · Guaranteeing Authors with TRPCError
    4. 54:46 · Polishing Post Rows and Relative Dates
  6. Loading States, Posting, and Rate Limiting
    1. 1:08:26 · Loading Spinner and Feed Extraction
    2. 1:19:52 · Auth-Aware tRPC Context and privateProcedure
    3. 1:20:58 · Creating Posts with Zod Validation
    4. 1:23:26 · Feed Fixes and Optimistic UX
    5. 1:31:31 · Rate Limiting with Upstash
    6. 1:34:06 · Toasts and Enter-Key Submission
  7. Routes, Static Generation, and Production Hardening
    1. 1:42:28 · Profile and Post Pages with Next.js Routing
    2. 1:59:25 · The Profile Router and filterUserForClient
    3. 2:04:26 · SSG Helper and getStaticProps
    4. 2:12:13 · Building the Profile Page UI
    5. 2:23:26 · Single Post Page
    6. 2:28:46 · CI, Build Speed, and Custom Domains

Unlike typical T3 demos, this walks a real app all the way to production: auth, rate limiting, observability, CI, static generation with ssgHelper, and custom domains — entirely on free tiers.

Who it's for
Read this guide if
  • You know basic React/TypeScript and want to see the T3 stack assembled end to end
  • You want opinionated guidance on auth, rate limiting, CI, and deployment choices
  • You learn best by following a real project from init to production URL
Skip ahead if
  • You want a beginner JavaScript course or Next.js fundamentals from scratch
  • You need a stack using NextAuth or a different database provider
  • You prefer testing-heavy tutorials with unit test coverage
In brief
  • Runtime: 10,742 seconds (~2 hours 59 minutes) of continuous project building.
  • 18 chapters grouped into 6 chronological modules, from project init to custom domains.
  • Tools: Create T3 App, Next.js, TypeScript, Tailwind, tRPC, Prisma, PlanetScale, Clerk, Vercel, Axiom, Upstash.
  • Level: intermediate — assumes comfort with React and TypeScript basics.
  • Goal: a deployed, type-safe emoji-only Twitter clone built entirely on free-tier services.

The walkthrough

Each chapter below is our original written explanation of what happens at that moment in the video — a paraphrase, not a transcript. Click any timestamp to jump the player.

Project Setup, Database, and First Deploy

0:00

Introduction

Theo introduces the project: a full Twitter clone called Chirp where users can only post emojis, built with the T3 stack from zero to production. He notes the stack is used by companies like Cal and every service has a generous free tier, and sponsors have no editorial influence.

2:08

Scaffolding with Create T3 App

The project starts with Create T3 App, choosing TypeScript, Clerk instead of NextAuth, Prisma, Tailwind, and tRPC. Theo explains his rule of initializing, pushing to GitHub, and deploying early, and picks NPM as the package manager since everyone has it installed.

4:50

Vercel Deploy and Environment Variables

The repo is imported into Vercel via GitHub. Create T3 App's environment validation throws errors in production when DATABASE_URL is missing, and secrets are gitignored by default and never shared publicly.

6:07

Setting Up PlanetScale

The default SQLite is swapped for PlanetScale, with the database region placed near the Vercel function region. The Prisma schema changes to the MySQL provider, and Prisma's relation mode emulates standard SQL relations since PlanetScale (Vitess) lacks them.

8:48

Prisma Workflow and First Production Deploy

Prisma Studio provides direct database access while prisma db push syncs the schema, and git add -p lets Theo stage changes selectively. The DATABASE_URL is added to Vercel, the function region set to US West, and the first production deploy is verified.

Authentication and Observability

11:43

Adding Clerk Auth

Clerk is chosen for authentication, configured with GitHub OAuth only. The app is wrapped in ClerkProvider, and a middleware file embeds auth state into every request, processing it on the edge before hitting the app.

16:18

Sign-In Flow and Conditional Rendering

A sign-in button is added with Clerk's SignIn component, and useUser() drives conditional rendering of sign-in versus sign-out. The auth changes are committed and deployed to production.

20:03

Logging with Axiom

Axiom is connected through Vercel's integrations so all project logs flow into it for easier searching. Theo prefers it over Vercel's newer logging system for more thorough log management.

Data Modeling and the First tRPC Endpoint

21:29

The Post Model

A Post model is created with a CUID id, a varchar(255) content string, and an authorId with an index for instant lookups by author. After schema changes, prisma db push and prisma generate regenerate the local types.

24:10

tRPC Routers and the Frontend/Backend Magic

A posts router is created with a publicProcedure for fetching all posts. Theo demonstrates tRPC's core appeal: fully autocompleted frontend calls like api.posts.getAll.useQuery() with command-click navigation between client and server code.

28:32

Seeding Data and Deploying the Feed

Prisma Studio is used to quickly add records without building UI, though Theo calls the tool awkward to validate in. React keys are added, changes are committed, and pushing to GitHub triggers automatic deployment.

Styling the Twitter Clone UI

30:33

Global Styles and Centered Layout

Existing styles are deleted and global styles go on the body with Tailwind, preferring the slate palette. A Twitter-style centered layout is built with flex, max-width applied only at the md breakpoint, and side borders using h-screen.

34:38

Top Navigation and Feed Structure

The top nav gets a bottom border, padding, and flex layout, while tweets are separated with borders. A React Query pattern of checking isLoading then data lets TypeScript know the data must exist.

37:22

Building the Create Post Wizard

A createPostWizard component is started as a reusable piece, rendering the signed-in user's profile image and an emoji input. Default browser input styles clash with the dark theme, so custom Tailwind classes are applied.

Merging Users into Posts

41:42

Fetching Post Data with Prisma and Clerk

Since users live in Clerk rather than the app database, the posts endpoint fetches posts from Prisma and then pulls author info from Clerk's getUserList, capped at 100. A filterUserForClient helper strips sensitive fields, returning only id, username, and profileImageUrl.

46:48

Building Author Objects and Derived Types

Filtered users are matched to posts by authorId, effectively creating a client-side relation. A PostView component is extracted, and its props are derived from the router output type using RouterOutputs — no manual typing needed.

52:18

Guaranteeing Authors with TRPCError

When TypeScript flags a possibly-undefined author, Theo throws a TRPCError if no author exists, guaranteeing every post has one. Rendering of the author image begins, and a stale-data issue is resolved by refreshing since hot reload can be unreliable.

54:46

Polishing Post Rows and Relative Dates

Post rows are styled with flex, gaps, and slate-colored usernames, guarding against null usernames. day.js with its relativeTime plugin renders dates as '18 hours ago', and images switch to next/image with explicit dimensions and remote patterns configured.

Loading States, Posting, and Rate Limiting

1:08:26

Loading Spinner and Feed Extraction

A reusable loading spinner component is created with an optional size prop, and the feed is split into its own component since it combines two data flows. Calling a hook just to prefetch works because React Query caches results with matching parameters.

1:19:52

Auth-Aware tRPC Context and privateProcedure

The tRPC context is wired to Clerk via getAuth, verifying JWTs server-side without calling Clerk. A middleware throws a TRPCError when no user exists, and privateProcedure is derived from publicProcedure so ctx.currentUser is guaranteed.

1:20:58

Creating Posts with Zod Validation

The create mutation validates input with Zod's emoji string schema, min 1 and max 280 characters, so tRPC rejects bad input automatically. The client uses api.posts.create.useMutation, and a brief 'Unauthorized' bug is traced to Clerk's incorrect types and fixed using the session user ID.

1:23:26

Feed Fixes and Optimistic UX

Posts are ordered newest-first with orderBy createdAt desc, the input is cleared on success, and the tRPC cache is invalidated via api.useContext(). The mutation's loading state disables the input and button while posting.

1:31:31

Rate Limiting with Upstash

Upstash Redis rate limiting is added, configured regionally and set to 3 requests per minute per user. When the limit is hit, a TOO_MANY_REQUESTS TRPCError blocks spam without touching the database.

1:34:06

Toasts and Enter-Key Submission

react-hot-toast shows errors including server-side Zod messages like 'Only emojis are allowed', and a spinner replaces the post button while loading. Enter-key submission is added, with a note that react-hook-form would be preferred for real apps to avoid sticky-key re-render issues.

Routes, Static Generation, and Production Hardening

1:42:28

Profile and Post Pages with Next.js Routing

New routes are created in the pages directory: post/[id].tsx and a catch-all slug.tsx for @username profile routes, linked via Next.js Link for client-side navigation. Default head metadata is placed in _app and overridden per page.

1:59:25

The Profile Router and filterUserForClient

A profile subrouter with getUserByUsername is created and wired to the root router, with a 404 handling for missing users. The shared filter moves into server helpers, and Theo explains that tRPC has no type definitions — inputs come from Zod validators and outputs are inferred.

2:04:26

SSG Helper and getStaticProps

getServerSideProps is rejected in favor of tRPC's ssgHelper with getStaticProps, so pages are treated as static assets hydrated with prefetched data. Fallback blocking generates pages on load, the leading '@' in the slug is stripped, and loading states disappear since data arrives pre-hydrated.

2:12:13

Building the Profile Page UI

The shared container becomes a PageLayout component, and the profile header is styled with the picture half-overlapping the banner using relative/absolute positioning and negative margins. getPostsByUserID is added to the posts router and rendered through a ProfileFeed component.

2:23:26

Single Post Page

PostView is extracted into its own component file, and a getById procedure with a NOT_FOUND TRPCError powers the single post page. Because rendering happens server-side via the ssg helper, the delivered HTML already contains correct SEO metadata, CDN-cached and fast.

2:28:46

CI, Build Speed, and Custom Domains

Type checking moves off Vercel builds into a free GitHub CI workflow (with a fake DATABASE_URL) roughly halving build times, alongside next.config ignoring build errors and enabling SWC minify. Theo sets up branch protection for self-review, then buys a domain on Vercel and assigns an emoji subdomain, before wrapping with improvement ideas: infinite queries, webhooks to sync Clerk users, and OG image generation.

Moment by moment

TimeWhy it matters
24:10Theo demonstrates tRPC's signature trick: autocompleted, type-safe frontend-to-backend calls with command-click navigation.
1:20:58Auth-aware privateProcedure plus Zod emoji validation make posting type-safe and spam-resistant end to end.
2:04:26The ssgHelper + getStaticProps pattern unlocks correct SEO metadata without abandoning tRPC.
2:28:46Moving type checks to free GitHub CI cuts Vercel build times nearly in half.
2:38:36An emoji subdomain is attached to the live production app — the finish line of the zero-to-prod journey.

Do this next

  1. Clone the chirp repo (github.com/t3dotgg/chirp) and rebuild it yourself, deploying each milestone to Vercel as Theo does.
  2. Implement one of Theo's suggested improvements: infinite queries for feed pagination, Clerk webhooks to sync users into your database, or Vercel OG image generation.
  3. Refactor the create-post wizard with react-hook-form sharing the same Zod emoji validator between client and server, as recommended in the video.

Common questions

Does building a T3 stack app really cost nothing?

Yes — every service used (Vercel, PlanetScale, Clerk, Axiom, Upstash) has a generous free tier, so the entire project goes from zero to production at $0.

Why Clerk instead of NextAuth?

Theo prefers Clerk's third-party auth flow, especially for mobile support. Clerk auto-handles callback URLs and OAuth keys in development, and this project restricts sign-in to GitHub OAuth only.

How does the app get correct SEO metadata without getServerSideProps?

It uses tRPC's ssgHelper with getStaticProps and fallback blocking, so pages are rendered server-side ahead of time with data hydrated into the HTML and cached on the CDN.

How is post spam prevented?

The create-post mutation uses Upstash Redis rate limiting (3 posts per minute per authenticated user), throwing a TOO_MANY_REQUESTS tRPC error without ever touching the database.

Spot a mistake?

Every chapter summary above is hand-checked against the video, but a three-hour tutorial is easy to mislabel. If you spot a wrong timestamp, a mischaracterized step, or an error, please tell us so we can fix it.

More course guides