An example Next.js application for PlanetScale with Hyperdrive
The Coffee Cluster — Next.js with Hyperdrive and PlanetScale
A sample Next.js app that demonstrates Cloudflare Hyperdrive accelerating database queries to PlanetScale Postgres.
About The Coffee Cluster
The Coffee Cluster is a reference app showing how to connect a Next.js frontend to a PlanetScale Postgres database through Cloudflare Hyperdrive. The app displays coffee-related data and serves as a practical example of how Hyperdrive reduces query latency by connection pooling and caching at the edge.
Hyperdrive sits between your Worker and your database. It maintains a pool of persistent connections to PlanetScale and caches query results at Cloudflare’s edge. For read-heavy workloads, this means repeated queries return from cache instead of round-tripping to the origin database.
Frameworks & Technologies Used
- Frontend: Next.js (server-rendered pages on Cloudflare Workers)
- Database: PlanetScale Postgres
- Acceleration: Cloudflare Hyperdrive (connection pooling and query caching)
Why Cloudflare for This Project?
- Hyperdrive for Database Acceleration: Queries to PlanetScale go through Hyperdrive’s connection pool. Repeated reads return cached results from the nearest Cloudflare data center instead of crossing the network to the database origin.
- Next.js on Workers: The app runs Next.js on Cloudflare Workers, demonstrating that full-stack frameworks work on the platform. Server-side rendering happens at the edge, close to users.