Headline: Refresh token rotation means the server issues a new refresh token on every refresh and invalidates the old one; reuse detection means that when an already-rotated refresh token comes back, the server revokes every token from that login. In a NestJS API behind a Next.js App Router frontend, I store only SHA-256 hashes of opaque refresh tokens in Postgres, rotate them with one compare-and-set UPDATE , and allow a 10-second grace window so parallel refreshes from the same browser are not mistaken for theft.
The session design I started from is a common one: a short-lived JWT access token and a 30-day refresh token, both in httpOnly cookies, and a refresh endpoint that signs a new access token and leaves the refresh token untouched. It works until the refresh token leaks. Whoever holds a copy has a 30-day session, and the server cannot tell the two holders apart.…