Node.js Conf Italy 2025 brought together the Italian Node.js community for two days of talks on performance, APIs, and modern JavaScript patterns. UUID v7 featured prominently in sessions on database primary keys and distributed tracing. See crypto.randomUUID() Browser Support for the built-in UUID v4 context.
Session highlights
UUID v7 as API primary keys
The main UUID session walked through migrating a Fastify REST API from UUID v4 to UUID v7 primary keys. Key takeaways:
crypto.randomUUID()(Node.js 14.17+) for UUID v4 — no dependency, FIPS-compliantuuidnpmv7()for UUID v7 — drop-in replacement, same string format- PostgreSQL index fragmentation drops from ~40% wasted pages (UUID v4) to near-zero (UUID v7)
WHERE id > $cursor ORDER BY idpagination replacesOFFSET— no count query needed
See UUID v7 for Cursor Pagination for the full keyset pagination pattern.
Correlation IDs in Fastify
A second session covered correlation ID middleware:
import Fastify from 'fastify';
import { v7 as uuidv7 } from 'uuid';
const app = Fastify();
app.addHook('onRequest', async (req, reply) => {
req.correlationId = (req.headers['x-correlation-id'] as string) ?? uuidv7();
reply.header('x-correlation-id', req.correlationId);
});
UUID v7 correlation IDs carry a timestamp — req.correlationId.slice(0, 8) gives the hex-encoded seconds component, enabling log-range queries without a startTime field. See UUID v7 in Microservices.
Code examples from the talks
Zero-dependency UUID v4
// No npm package needed — crypto.randomUUID() is built in
const id = crypto.randomUUID(); // Node.js 14.17+, Bun, Deno, Edge runtimes
UUID v7 with Prisma
import { v7 as uuidv7 } from 'uuid';
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function createOrder(customerId: string) {
return prisma.order.create({
data: {
id: uuidv7(), // override Prisma's default
customerId,
status: 'pending',
},
});
}
See UUID in Prisma — setup and migration for the full schema configuration.
UUID v7 time-range query
function uuidV7Lower(ms: number): string {
const hex = ms.toString(16).padStart(12, '0');
return `${hex.slice(0,8)}-${hex.slice(8,12)}-7000-8000-000000000000`;
}
// All orders in the last hour
const recent = await prisma.order.findMany({
where: { id: { gte: uuidV7Lower(Date.now() - 3_600_000) } },
orderBy: { id: 'asc' },
});
See UUID in Databases for the index strategy behind this query.
Further reading
- UUID v7 in Microservices — correlation IDs
- UUID v7 for Cursor Pagination
- UUID in JavaScript — full guide
- UUID in Prisma — v7 setup
- UUID v4 vs v7 — performance comparison
External references
Frequently asked questions
What UUID approach was recommended at Node.js Conf Italy 2025?
Talks recommended crypto.randomUUID() (built-in, no dependency) for UUID v4, and the uuid npm package's v7() export for UUID v7. For new APIs with PostgreSQL, the consensus was to switch primary keys to UUID v7 — the timestamp prefix eliminates B-tree fragmentation and removes the need for a separate created_at index for time-range queries. See crypto.randomUUID() Browser Support.
How does UUID v7 improve Fastify API performance?
UUID v7 reduces database write amplification. Random UUID v4 primary keys cause B-tree page splits on every insert as rows land in random index positions. UUID v7's monotonic timestamp prefix means new rows always insert at the end of the B-tree — the same access pattern as an auto-increment integer. Talks cited 20–40% insert throughput improvements on PostgreSQL tables over 10M rows. See UUID v4 vs v7.