Node.js Interactive 2025 was held in Dublin, Ireland on September 9–10, 2025. Hosted by the OpenJS Foundation, the event brought together Node.js core contributors, framework maintainers, and backend engineers for two days of talks on performance, security, and API design.
The State of UUID in Node.js
Sessions opened by reviewing the current state: crypto.randomUUID() ships in Node.js 18+ and generates UUID v4 using the platform CSPRNG. It is fast, secure, and requires no npm dependency — but it only generates v4.
The uuid npm package (v9+) fills the gap with v7():
import { v7 as uuidv7 } from 'uuid';
const id = uuidv7(); // "018fbe3a-4c5d-7000-8abc-0123456789ab"
The package implements RFC 9562’s recommended monotonic counter within each millisecond — consecutive calls return lexicographically increasing values even when the system clock has not advanced.
Fastify Integration
Talks on API framework patterns showed how to inject UUID v7 into Fastify route handlers cleanly:
import Fastify from 'fastify';
import { v7 as uuidv7 } from 'uuid';
const app = Fastify();
app.post('/orders', async (request, reply) => {
const order = {
id: uuidv7(),
...request.body,
};
await db.orders.insert(order);
return reply.code(201).send(order);
});
For Fastify’s request ID generation (used in logs), speakers recommended configuring genReqId to use uuidv7() so request IDs are time-sortable — making log correlation by request ID straightforward without a separate timestamp field:
const app = Fastify({
genReqId: () => uuidv7(),
logger: true,
});
Prisma and Drizzle ORM Patterns
A dedicated session covered UUID v7 integration with the two leading TypeScript ORMs.
Prisma with PostgreSQL 18:
model Order {
id String @id @default(dbgenerated("uuidv7()")) @db.Uuid
}
This pushes generation to the database layer — every insert, whether from Prisma or raw SQL, gets a v7 UUID. For older PostgreSQL versions, generate in the application:
import { v7 as uuidv7 } from 'uuid';
const order = await prisma.order.create({
data: { id: uuidv7(), customerId, total },
});
Drizzle ORM with $defaultFn:
import { v7 as uuidv7 } from 'uuid';
import { pgTable, uuid } from 'drizzle-orm/pg-core';
export const orders = pgTable('orders', {
id: uuid('id').primaryKey().$defaultFn(() => uuidv7()),
});
crypto.randomUUID() vs uuid Package
A panel discussion addressed when to use each:
| Scenario | Recommendation |
|---|---|
| UUID v4 only, no npm dependency | crypto.randomUUID() |
| UUID v7 for primary keys | uuid package v7() |
| High-throughput, within-ms ordering | uuid package (includes monotonic counter) |
| Edge runtime (Cloudflare Workers) | crypto.randomUUID() for v4; uuid package for v7 |
The panel consensus: crypto.randomUUID() is fine for session tokens and idempotency keys where v4 is acceptable. For anything stored as a primary key in a relational database, use the uuid package with v7().
Related Node.js Resources
- uuid npm package — UUID v4 and v7 for Node.js and browsers
- Node.js crypto.randomUUID() documentation
- Fastify documentation
- Prisma ORM documentation
- Drizzle ORM documentation
Frequently asked questions
Have Node.js conferences covered UUID v7?
Yes. Node.js Interactive 2025 in Dublin covered uuid npm v7(), the limitations of crypto.randomUUID() (v4 only), Fastify request ID patterns, and Prisma and Drizzle ORM UUID v7 configuration. The OpenJS Foundation hosts the event and archives session recordings.
Does JavaScript have a built-in UUID generator?
Yes for v4: crypto.randomUUID() is available in all modern browsers and Node.js 19+. For v7 there is no built-in — use a library like the uuid npm package or a short RFC 9562-compliant implementation.
Should I use v4 or v7?
Use v7 for database primary keys (time-sortable, index-friendly) and v4 for anything where creation order could leak information, like tokens or share links.
Does Node.js have built-in UUID v7 support?
Node.js 18+ includes crypto.randomUUID() which generates UUID v4 only. For UUID v7, use the uuid npm package version 9+: import { v7 as uuidv7 } from 'uuid'. A Node.js core UUID v7 proposal exists but has not been merged as of 2026.
Can I use UUID v7 with Prisma?
Prisma does not natively generate UUID v7, but you can set default(dbgenerated("uuidv7()")) in your schema when using PostgreSQL 18, or use @default(uuid()) and override it with application-generated v7 values. The Prisma documentation on default values covers both approaches.