UUID Use Case
UUID Event ID
In event sourcing, events are the source of truth. A UUID event ID makes each immutable fact addressable and replayable.
Event-sourcedReplayablev7 for order
Generated locally with the Web Crypto API — nothing leaves your browser.
What Is UUID Event ID?
- A v7 UUID as event ID gives you a time-ordered, unique handle — handy when you replay a stream in chronological order.
- The UUID also lets you dedupe events that a producer might emit twice.
How to generate
- Mint a v7 UUID per emitted event.
- Append to the stream keyed by aggregate.
- Use the id to skip duplicates on replay.
Use Cases
- Event sourcing stores.
- CQRS read-model builds.
- Audit logs.
Code Examples
JavaScript
import { v7 as uuidv7 } from 'uuid';
const id = uuidv7(); // time-orderedPython
import uuid
id = uuid.uuid7() # RFC 9562 time-orderedFrequently Asked Questions
v4 or v7 for events?
v7 if you want time-ordering for free (great for replay); v4 if order comes from a separate sequence.
Can I use the event ID as a key?
Yes — it is unique per event, ideal as the stream row's primary key.
Related tools
UUID v1 GeneratorUUID v3 GeneratorUUID v4 GeneratorUUID v5 GeneratorUUID v6 GeneratorUUID v7 GeneratorUUID v8 GeneratorBulk UUID GeneratorShort UUID GeneratorUUID ValidatorUUID FormatterUUID as a Primary KeyUUID Database IDUUID Foreign KeyUUID Shard KeyUUID Partition KeyUUID in a Composite KeyUUID Surrogate KeyUUID API KeyUUID Session TokenUUID Access TokenUUID Refresh TokenUUID Idempotency KeyUUID Request IDUUID Correlation IDUUID Trace IDUUID CSRF TokenUUID NonceUUID FilenameUUID Object KeyUUID S3 KeyUUID Upload IDUUID Cache KeyUUID Blob NameUUID Temp FileUUID User IDUUID Account IDUUID Customer IDUUID Device IDUUID Tenant IDUUID Client IDUUID Anonymous IDUUID Member IDUUID Message IDUUID Event IDUUID Job IDUUID Task IDUUID Queue Message IDUUID Transaction IDUUID Order IDUUID Invoice IDUUID Payment IDUUID Reset TokenUUID Verification TokenUUID Invite CodeUUID API SecretUUID Share LinkUUID Magic LinkUUID Node IDUUID Worker IDUUID Lock IDUUID Cluster IDUUID Test DataUUID Seed DataUUID FixtureUUID Mock IDUUID Placeholder IDUUID Sample ID