NodeConf EU is the premier European Node.js conference, held annually in Killarney, Ireland. NodeConf EU 2025 featured a full track on identifier patterns — with UUID v7 replacing UUID v4 as the recommended default for new Node.js applications. See UUID in JavaScript for the full guide.
Event details
| Conference | NodeConf EU 2025 |
| Date | November 2–4, 2025 |
| Location | Killarney, Ireland |
| Focus | UUID v7 in Node.js — uuid package, Fastify, database patterns, idempotency |
Key sessions
uuid npm package v7 API
import { v7 as uuidv7, validate, version, parse } from 'uuid';
// Generate UUID v7
const id = uuidv7();
console.log(id); // '018fbe3a-4c5d-7b12-8f3e-1a2b3c4d5e6f'
validate(id); // true
version(id); // 7
// Extract creation time (client-side)
const bytes = parse(id);
const ms = (BigInt(bytes[0]) << 40n) | (BigInt(bytes[1]) << 32n) |
(BigInt(bytes[2]) << 24n) | (BigInt(bytes[3]) << 16n) |
(BigInt(bytes[4]) << 8n) | BigInt(bytes[5]);
const createdAt = new Date(Number(ms));
// Custom timestamp (useful for testing)
const seeded = uuidv7({ msecs: new Date('2025-01-01').getTime() });
crypto.randomUUID() vs uuidv7(): the gap
// Built-in — UUID v4 only
const v4 = crypto.randomUUID();
// No timestamp, random sort order
// uuid package — UUID v7 with timestamp
import { v7 as uuidv7 } from 'uuid';
const v7 = uuidv7();
// Timestamp prefix, chronological sort
// Sorting behavior
const ids4 = [crypto.randomUUID(), crypto.randomUUID(), crypto.randomUUID()];
ids4.sort(); // Random order — not useful
const ids7 = [uuidv7(), uuidv7(), uuidv7()];
ids7.sort(); // Chronological order ✓
See crypto.randomUUID() Browser and Runtime Support.
PostgreSQL primary keys with Node.js + pg
import pg from 'pg';
import { v7 as uuidv7 } from 'uuid';
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });
// Insert with UUID v7 primary key
async function createOrder(customerId: string, total: number) {
const id = uuidv7();
const result = await pool.query(
'INSERT INTO orders (id, customer_id, total) VALUES ($1, $2, $3) RETURNING *',
[id, customerId, total]
);
return result.rows[0];
}
// Cursor pagination — UUID v7 lexicographic = chronological
async function listOrders(cursor?: string, limit = 20) {
const query = cursor
? 'SELECT * FROM orders WHERE id > $1 ORDER BY id LIMIT $2'
: 'SELECT * FROM orders ORDER BY id LIMIT $1';
const args = cursor ? [cursor, limit] : [limit];
const result = await pool.query(query, args);
const nextCursor = result.rows.length === limit ? result.rows.at(-1).id : null;
return { orders: result.rows, nextCursor };
}
Fastify with UUID v7 request IDs
import Fastify from 'fastify';
import { v7 as uuidv7 } from 'uuid';
const app = Fastify({
genReqId: () => uuidv7(), // UUID v7 per request
logger: {
level: 'info',
// reqId appears in every log line — UUID v7 timestamp = request time
},
});
app.addHook('onSend', (request, reply, payload, done) => {
reply.header('X-Request-Id', request.id); // Return UUID v7 to client
done();
});
app.post('/orders', async (request, reply) => {
console.log(`[${request.id}] Creating order`); // UUID v7 trace ID
const order = await createOrder(request.body);
return reply.status(201).send(order);
});
Conference takeaways
- Replace
crypto.randomUUID()withuuid.v7()for new projects that need time-ordered IDs - Fastify
genReqIdis the correct place to inject UUID v7 trace IDs ORDER BY idreplacesORDER BY created_atfor UUID v7 primary keys- No inter-process coordination needed for cluster workers — 74 random bits suffice
- Backward compatible — UUID v7 parses with the same
uuid.validate()anduuid.version()APIs as v4
Further reading
- UUID in JavaScript — Full Guide
- crypto.randomUUID() Browser and Runtime Support
- UUID v7 in NestJS with Fastify
- UUID v7 for Cursor Pagination
- JSWorld 2026 — UUID v7 in JavaScript
External references
Frequently asked questions
What is the difference between crypto.randomUUID() and uuid v7() in Node.js?
crypto.randomUUID() generates UUID v4 — 122 bits of random data with no timestamp. It is available in Node.js 14.17+ without any npm packages. uuid.v7() from the uuid npm package generates UUID v7 — a 48-bit Unix millisecond timestamp plus 74 random bits. UUID v7 sorts chronologically; UUID v4 does not. For database primary keys, UUID v7 is preferred. See crypto.randomUUID() Browser and Runtime Support.
How do I use UUID v7 with Fastify in Node.js?
Configure Fastify's genReqId option: const app = Fastify({ genReqId: () => uuidv7() }). Every request gets a UUID v7 request ID that encodes arrival time. Access it in handlers via request.id. Set it on response headers with reply.header('X-Request-Id', request.id) to return trace IDs to clients. See UUID v7 in NestJS with Fastify.
How does UUID v7 work with Node.js cluster module?
Node.js cluster spawns multiple worker processes. Each worker independently generates UUID v7 values — the 74 random bits provide collision resistance without any inter-process coordination. UUID v7 is safe to generate in any Node.js cluster worker. The timestamp prefix comes from the system clock, which is shared across all cluster workers on the same machine.