RebrandX: The X Clone That Treats Real-Time as a UX Trick, Not a WebSocket Problem

A deep look at a Next.js 15 social stack where Clerk, Prisma, tRPC, and React Query are wired together to make feeds feel instant, threads stay type-safe, and identity sync cleanly across systems.

8 min read • View on GitHub • More from BensonRaro

A wide editorial scene of a social feed built like a mechanical printing press. An identity seal stamps user records on one side, typed feed cards travel through a conduit in the middle, and a looping refresh arm keeps a cache tank topped up on the other side. The image explains how the app turns multiple systems into one responsive experience.
RebrandX makes the feed feel alive by treating data flow as an assembly line, not a pile of disconnected UI states.
Key Takeaways

The strange thing about RebrandX is that it feels live before it earns the right to. The feed arrives preloaded, the cache is already warm, and the UI keeps checking back so fast that the difference between fresh and fetched almost disappears. That is not a websocket story. It is a product choice.

This repo is best read as a systems diagram disguised as a social app. Clerk handles identity. Prisma stores the local graph. tRPC makes every mutation compile-time safe. React Query keeps the screen moving. The result is a clone that is less about imitation and more about how much responsiveness you can buy with careful plumbing.

The feed feels alive before the architecture even shows itself

The core trick lives in the handoff between server and client. The page prefetches feed data on the server, seeds the client cache through a hydration boundary, and then lets a suspense query keep refreshing it. The first paint is already useful, which means the app avoids the dead air that makes many social feeds feel slow even when the backend is not.

The feed is not really real-time in the infrastructural sense. It is rendered, hydrated, and then refreshed so aggressively that it behaves like it is.

Why Clerk is not the source of truth

Clerk solves authentication, but it does not solve the social graph. RebrandX mirrors users into its own database through a verified webhook flow, which gives the app something a managed auth service cannot: relational control. Once a user exists in Prisma, followers, likes, posts, and threaded replies become ordinary database problems instead of vendor-specific workarounds.

That is the important architectural move. The app does not ask Clerk to be its entire identity layer. It uses Clerk as the entry point, then copies the necessary shape of that identity into a database it owns. That is what makes feed queries, profile pages, and social connections possible without awkward abstractions.

Conventional auth-first stackRebrandX pattern
Auth provider owns the user recordAuth provider verifies identity, app mirrors users locally
Relational queries are bolted on laterFollowers, likes, and posts live in Prisma from the start
App logic depends on provider shapeApp logic depends on its own schema
Identity and data drift apartWebhook sync keeps the local graph current

tRPC turns social mutations into compile-time contracts

The tRPC layer is where the project stops feeling like a tutorial and starts feeling like a coherent system. Protected procedures gate actions like follow and createPost, which means the server and client agree on more than just route names. They agree on the shape of the data, the permissions around it, and the failure modes when something is missing.

export const protectedProcedure = t.procedure.use(({ ctx, next }) => {
  if (!ctx.user) {
    throw new TRPCError({ code: 'UNAUTHORIZED' });
  }

  return next({
    ctx: {
      ...ctx,
      user: ctx.user,
    },
  });
});

export const feedRouter = t.router({
  createPost: protectedProcedure
    .input(createPostSchema)
    .mutation(async ({ ctx, input }) => {
      return ctx.db.post.create({
        data: {
          content: input.content,
          authorId: ctx.user.id,
        },
      });
    }),
});

That matters more in a social product than in a CRUD demo. Social apps accumulate edge cases quickly: private profiles, reply chains, reposts, likes, follows, media, mentions, and permission boundaries. A typed procedure layer keeps those concerns in one place instead of scattering them across route handlers and client assumptions.

Threads are modeled as links, not a separate universe

The thread model is one of the cleaner ideas in the repo. Replies are tied back through a replayId pattern, so a conversation remains part of the same graph rather than being treated as a separate feature island. That keeps the mental model simple: a post can have descendants without requiring an entirely different content system.

This is the right kind of social modeling. The feed stays one thing. Replies are just a different edge in the same structure. That makes navigation, rendering, and moderation easier to reason about because the data still obeys the same rules of origin and ownership.

Separate thread systemLinked thread model
Replies live in their own subsystemReplies remain attached to the feed graph
Rendering logic forks earlyRendering logic reuses the same post shape
More special casesFewer concepts to maintain
Harder to extendEasier to chain posts, replies, and reposts
A close-up of a post composer where typed @ and # characters are highlighted as the cursor hovers beside a floating autocomplete panel. A hidden measuring grid sits behind the text field like drafting equipment. The image explains that a simple composer hides precise cursor tracking and tokenization logic.
The composer looks ordinary, but it is doing careful spatial work to keep mentions and hashtags aligned with the caret.

The post composer is more sophisticated than it looks

The composer is the best example of the repo’s attention to interaction detail. It highlights mentions and hashtags as you type, and it uses caret measurement logic to place the autocomplete panel exactly where the cursor is. That sounds small. It is not. It is the difference between a feature that merely works and one that feels native.

This is where RebrandX earns its social-app credibility. A plain-looking modal is doing regex parsing, token styling, and cursor tracking at the same time. The UI stays calm because the code underneath is doing more than the interface ever admits.

const renderHighlighterText = (value: string) =>
  value.replace(/(@\w+|#\w+)/g, (match) => `<mark>${match}</mark>`);

const updateCaretPosition = () => {
  const rect = caretMeasureRef.current?.getBoundingClientRect();
  if (!rect) return;
  setSuggestionPosition({
    top: rect.top,
    left: rect.left,
  });
};

The stack is modern, but not production-polished yet

The tech choices are sharp. Next.js 15, Turbopack, Tailwind 4, Bun, Clerk, Prisma, and ImageKit make for a fast, modern developer experience. But the repo still shows the fingerprints of a high-velocity build: hardcoded environment assumptions, tutorial-adjacent structure, and a few signals that suggest the code is closer to a strong prototype than a hardened platform.

That does not weaken the project. It clarifies it. RebrandX is useful because it shows what a focused team can assemble when the goal is not to invent a new platform category, but to make a social product feel real, type-safe, and maintainable without overengineering the transport layer.

Polished production systemRebrandX today
Strictly abstracted infrastructureFast-moving app with visible implementation choices
Websocket or event-driven realtimeHydration plus aggressive polling
Fully normalized everythingPragmatic relational modeling with some shortcuts
Broad platform ambitionClear blueprint for a social stack

What RebrandX is really teaching

The lesson is not that polling is better than websockets. It is that product feel and transport purity are not the same problem. RebrandX spends complexity where it matters most, in identity sync, typed mutations, and immediate-feeling interactions, while borrowing simplicity where it can, in the live feed loop.

That tradeoff is the real design move. If the goal is a social app that feels responsive without becoming an infrastructure project, this repo shows a plausible path. It is not maximalist. It is disciplined, pragmatic, and very aware of where the user notices latency.