When we upgraded our Next.js 16 app to Tailwind CSS v4, almost everything worked out of the box—except one interactive component that suddenly felt janky.

On Tarot Fortune Cards, visitors draw cards from an overlapping 22-card fan before receiving a reading. After moving to Tailwind v4, hovering and selecting a card snapped abruptly instead of gliding smoothly—and every card click still took over a second to settle.

Root-causing that single interaction uncovered two completely separate bugs: a Tailwind v4 CSS compilation change that quietly breaks transition-[transform], and a 6-query database waterfall hiding inside a tiny Next.js Route Handler. Here is how we fixed both in under an hour.

Bug 1: Why transition-[transform] Stops Animating -translate-y-5 in Tailwind v4

In Tailwind v3, utility classes like -translate-y-5 and scale-[1.05] compiled down to CSS custom properties inside a single transform: declaration:

/* Tailwind v3 output */ .hover\:-translate-y-5:hover { --tw-translate-y: -1.25rem; transform: translate(var(--tw-translate-x), var(--tw-translate-y)) scaleX(...) scaleY(...); } 

So writing transition-[transform,opacity] animated hover lifts and scale jumps seamlessly.

In Tailwind v4, translate and scale utilities compile to the modern individual CSS transform properties (translate and scale), not the legacy transform shorthand:

/* Tailwind v4 output */ .group:hover .group-hover\:-translate-y-5 { translate: var(--tw-translate-x) -1.25rem; } .group:hover .group-hover\:scale-\[1\.05\] { scale: 1.05 1.05; } 

Because translate and scale are distinct CSS properties from transform, an explicit transition-[transform,opacity,border-color,box-shadow] completely ignores them! The card teleports instantly on hover and snaps back abruptly on click.

The Fix

List translate and scale explicitly in both transition-[...] and will-change-[...]:

<div className={`relative h-full w-full overflow-hidden rounded-[14px] border will-change-[translate,scale,opacity] transition-[transform,translate,scale,opacity,border-color,box-shadow] duration-300 ease-out ${ isRemoved ? '-translate-y-[116px] scale-[0.94] opacity-0' : isClicked ? '-translate-y-[84px] scale-[1.08] opacity-100' : 'translate-y-0 scale-100 opacity-100 group-hover:-translate-y-5 group-hover:scale-[1.05]' }`} > 

Keep transform in the transition list too if you combine Tailwind utilities with inline style={{ transform: rotate(...) }} for fan arc positioning. The instant we added translate,scale, every card hover, lift, and fade-out returned to silky 60fps.

(If you want to feel the live difference, try hovering and pulling a card on our interactive is he thinking about me tarot draw deck.)

Bug 2: The 6-Query Database Waterfall Inside /api/reading/draw

Even after the CSS glide was smooth, clicking a card still lagged behind the animation. Checking server timing on our serverless PostgreSQL route (POST /api/tarot/reading/draw) showed why: every single click was running 6 sequential database roundtrips!

  1. findTarotSessionById(sessionId)
  2. getSpreadById(session.spreadId) (static config table that almost never changes)
  3. countSessionCards(sessionId)
  4. getAllCards() (fetching full upright/reversed prose descriptions for all 78 cards on every draw!)
  5. getDrawnCardIds(sessionId) (redundant with #3!)
  6. insertSessionCard(...)

On a remote serverless Postgres database, 5 serial read roundtrips + 1 write easily burned 1.1–1.4 seconds per card click.

The Fix: Promise.all + Narrow Projection + Warm-Instance Static Cache

A tarot deck always has the same 78 cards, and spread definitions rarely change. During the draw step, we only need { id, name }—not multi-paragraph card meanings.

We added a 10-minute in-memory TTL cache for static deck/spread metadata on warm serverless instances, eliminated the redundant COUNT(*) query (drawnCardIds.length already gives the exact count), and ran the remaining reads in parallel:

const STATIC_CACHE_TTL_MS = 10 * 60 * 1000; let drawDeckCache: { value: Array<{ id: string; name: string }>; expiresAt: number } | null = null; export async function getCachedDrawDeck() { const now = Date.now(); if (drawDeckCache && drawDeckCache.expiresAt > now && drawDeckCache.value.length > 0) { return drawDeckCache.value; } const rows = await db() .select({ id: tarotCard.id, name: tarotCard.name }) .from(tarotCard); if (rows.length > 0) { drawDeckCache = { value: rows, expiresAt: now + STATIC_CACHE_TTL_MS }; } return rows; } 

And inside the Route Handler:

// Collapse 5 serial reads into 1 parallel roundtrip (+ warm in-memory cache) const [session, drawnCardIds, allCards] = await Promise.all([ findTarotSessionById(sessionId), getDrawnCardIds(sessionId), getCachedDrawDeck(), ]); const spread = await getCachedSpreadById(session.spreadId); const drawnCount = drawnCardIds.length; // replaces redundant COUNT(*) query 

Measured Result

  • Serial reads per click: 5 → 1 parallel batch (with static deck + spread served from memory on warm instances)
  • Payload transferred from Postgres: Full 78-row prose table → cached { id, name } array
  • End-to-end draw latency: Dropped from ~1.4s down to ~0.55s, matching the 300ms card-lift animation cleanly without awkward spinner flicker.

Quick Checklist If You Recently Upgraded to Tailwind v4

  1. Grep your codebase for transition-[transform or will-change-transform paired with translate-*, scale-*, or rotate-* utilities—add translate, scale, and rotate explicitly (or use Tailwind's built-in transition-transform shorthand, which v4 updates automatically).
  2. Audit your interactive Route Handlers for "static reference table" reads hiding inside hot click paths—especially full SELECT * queries where you only need IDs.

Have you run into any other subtle CSS property shifts after migrating from Tailwind v3 to v4?