UUID Use Case

UUID User ID

A user ID is the most-shown identifier in your app. A UUID keeps it unguessable and hides how many users you have.

OpaqueURL-safeCount-hidden

Generated locally with the Web Crypto API — nothing leaves your browser.

What Is UUID User ID?

How to generate

  1. Default the users.id column to a UUID generator.
  2. Use it in URLs and API responses.
  3. Keep email/username unique via a separate constraint.

Use Cases

Code Examples

PostgreSQL
CREATE TABLE users (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  email TEXT UNIQUE
);
JavaScript
const id = crypto.randomUUID();

Frequently Asked Questions

Why not an integer user ID?
Integers leak count and are enumerable; UUIDs are opaque and merge-safe across shards.
Show the UUID in the URL?
Yes — it is safe to expose; that is the point of an opaque id.

Related tools