Watt 3.18 Empowers Self-Hosted Next.js 16 with 'use cache' and Distributed Redis/Valkey Caching
Share this article
Watt 3.18 Empowers Self-Hosted Next.js 16 with 'use cache' and Distributed Redis/Valkey Caching
Next.js 16 marks a pivotal evolution in React Server Components caching, introducing the explicit 'use cache' directive for unprecedented precision. While this unlocks surgical performance optimizations, production deployment—particularly in self-hosted environments—demands distributed infrastructure to avoid pitfalls like cache fragmentation. Enter Watt 3.18.0 from Platformatic: a Node.js server that seamlessly enables this capability with a Redis/Valkey adapter, transforming how developers scale Next.js apps beyond Vercel.
As outlined in Platformatic's announcement, this release addresses a core tension in modern web development: balancing fine-grained caching with horizontal scalability.
Next.js 16's Caching Paradigm Shift
Previous Next.js versions relied on implicit caching, often leading to opaque behavior and tricky invalidation. Next.js 16 flips the script with explicit directives, applicable at component, function, or module scope:
// Component-level caching
export async function ProductList() {
"use cache";
const products = await fetchProducts();
return <div>{/* render products */}</div>;
}
// Function-level caching
export async function getProductData(id) {
"use cache";
const data = await fetch(`/api/products/${id}`);
return data.json();
}
// File-level caching
("use cache");
export default async function Page() {
// page logic
}
This granularity empowers developers to cache precisely where it matters, reducing over-fetching and compute costs. Yet, in single-server setups, Next.js defaults to local file-system caching—fine for dev, disastrous for production clusters.
The Self-Hosting Caching Crisis
In Kubernetes or load-balanced deployments, each Next.js replica maintains its own cache. Consequences include:
- Inconsistencies: Users see stale or varying data based on routing.
- Resource Waste: Redundant fetches inflate database/API strain.
- Invalidation Nightmares: Coordinating updates across instances is error-prone.
Vercel sidesteps this via its shared Data Cache, but self-hosters must build their own. Watt 3.18.0 changes that with a plug-and-play Redis/Valkey backend, centralizing caches for consistency and efficiency.
Watt: Orchestration for Modern Apps
Watt is more than a server—it's an extensible platform for composing Next.js frontends with microservices, offering multi-threading, monitoring, and zero-config deploys. The v3.18 update adds first-class Next.js 16 support, including:
cacheComponents: trueto activate directive-based caching.- Automatic Next.js cache handler configuration.
- Shared storage via Redis/Valkey for all replicas.
Setup requires minimal watt.json tweaks:
{
"cache": {
"adapter": "valkey",
"url": "valkey://redis.example.com:6379",
"cacheComponents": true
}
}
Watt manages keys, serialization, and pipelining, leveraging Valkey's low-latency strengths for production workloads.
"Watt handles all the complexity behind the scenes." — Platformatic Blog
Architectural Trade-offs
Note: Enabling component caching disables Incremental Static Regeneration (ISR) in Next.js 16, as the architectures conflict. ISR-dependent apps can disable cacheComponents to retain legacy behavior while accessing other Next.js 16 upgrades.
Broader Implications
This integration signals the maturation of open-source tooling for edge caching. Developers escape vendor ecosystems, deploying performant Next.js apps on Kubernetes, bare metal, or hybrid clouds with Vercel-equivalent guarantees. As frameworks push explicit control, servers like Watt ensure these advances reach production without custom plumbing—paving the way for resilient, scalable web apps in diverse infrastructures.