Skip to content
← All workCase 04 / 06

Twitter Clone

Social timeline

Year
2022 — 23
Built with
Next.js 13, React 18, TypeScript, Tailwind CSS 3 +7 more ↓
twitter-tanzimshahriar.vercel.app
Twitter Clone — screenshot of the live site

(01) Overview

A Twitter-style social app on the T3 stack. Post to a shared timeline, like and reply in threads, open anyone’s profile, and see the most-liked posts in the sidebar.

(02) Features

  1. 01Three ways inA username and password, or OAuth with Facebook or Discord.
  2. 02Endless timelineCursor-paginated, and the next page loads as you near the end.
  3. 03ThreadsEvery tweet has a page of its own with its replies; delete a tweet and its replies go with it.
  4. 04Likes and top postsLike and unlike, and a sidebar ranks the most-liked posts.
  5. 05ProfilesEvery author has a profile with their tweets.

(03) Screens

twitter-tanzimshahriar.vercel.app
Twitter Clone — A tweet and its replies
03.1A tweet and its replies
twitter-tanzimshahriar.vercel.app
Twitter Clone — Sign in with a password, Facebook or Discord
03.2Sign in with a password, Facebook or Discord
twitter-tanzimshahriar.vercel.app
Twitter Clone — A profile
03.3A profile

(04) On a phone

Same app, smaller screen.

Captured from the live site at 390 pixels wide — the width of most phones in a hand.

Twitter Clone on a phone — The timeline on a phone
The timeline on a phone

(05) Stack

Eleven tools, and the job each one does here.

  • FrameworkNext.js13Pages Router, scaffolded with create-t3-app
  • UIReact18Timeline, threads, modals and toasts
  • LanguageTypeScriptOne set of types from the database to the button
  • StylingTailwind CSS3The interface
  • APItRPC10Public procedures for reading, protected ones for writing
  • DataTanStack Query4Infinite queries for the timeline, replies and top posts
  • DataPrisma4Schema, six migrations and a Faker seed
  • DataPostgreSQLUsers, tweets and likes
  • DataZodProcedure input and the environment schema
  • AuthNextAuthCredentials with bcrypt, Facebook and Discord
  • HostingVercelProduction hosting

(06) Under the hood

  1. 01

    tRPC routers carry types from the Prisma schema to the React components; anything that writes — tweet, like, unlike, delete — is a protected procedure.

  2. 02

    Lists are cursor-paginated on the server and read with TanStack Query’s infinite queries, so the timeline, replies and top posts share one pattern.

  3. 03

    Accounts made with a password and accounts made through Facebook or Discord share one users table through the NextAuth Prisma adapter.

  4. 04

    A Faker seed script fills the database with users and tweets for local development.

Next case

POJO Generator