Skip to content

Commit 9564453

Browse files
committed
Fix remaining Next.js 16 compatibility issues and update documentation
Changes: - Remove duplicate file (page copy.tsx) - Fix static-params-test page: replace 'export const revalidate' with 'use cache' - Update README with comprehensive Next.js 16 migration guide - Add version compatibility table - Document breaking changes and upgrade path - Add configuration examples for Next.js 16 All tests passing ✅
1 parent 4010fa8 commit 9564453

File tree

3 files changed

+62
-29
lines changed

3 files changed

+62
-29
lines changed

README.md

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,82 @@
33
# @fortedigital/nextjs-cache-handler
44

55
A caching utility built originally on top of [`@neshca/cache-handler`](https://www.npmjs.com/package/@neshca/cache-handler), providing additional cache handlers for specialized use cases with a focus on Redis-based caching.
6-
Starting from version `2.0.0`, this package no longer depends on `@neshca/cache-handler` and is fully maintained and compatible with Next.js 15 and onwards.
6+
7+
**Version compatibility:**
8+
- Version `3.x.x`: Next.js 16+ (with "use cache" and cacheComponents support)
9+
- Version `2.x.x`: Next.js 15+ (legacy)
10+
- Version `1.x.x`: Next.js 14 and earlier (deprecated)
11+
12+
Starting from version `2.0.0`, this package no longer depends on `@neshca/cache-handler` and is fully maintained independently.
713

814
## Documentation
915

1016
The documentation at [@neshca/cache-handler - caching-tools.github.io/next-shared-cache](https://caching-tools.github.io/next-shared-cache) is mostly still relevant, though some details may be outdated. New features or relevant changes are described below.
1117

1218
## Migration
1319

20+
- [2.x.x → ^3.x.x (Next.js 16)](#nextjs-16-migration)
1421
- [1.x.x → ^2.x.x](https://github.com/fortedigital/nextjs-cache-handler/blob/master/docs/migration/1_x_x__2_x_x.md)
1522
- [1.2.x -> ^1.3.x](https://github.com/fortedigital/nextjs-cache-handler/blob/master/docs/migration/1_2_x__1_3_x.md)
1623

17-
## Installation
24+
### Next.js 16 Migration
1825

19-
`npm i @fortedigital/nextjs-cache-handler`
26+
Version 3.0.0 adds full support for Next.js 16 with the following key changes:
27+
28+
**Breaking Changes:**
29+
- Requires Next.js 16.0.0 or later
30+
- The cache handler API now supports the optional `durations` parameter in `revalidateTag(tag, durations?)`
31+
32+
**App Router Changes:**
33+
When using `cacheComponents: true` in Next.js 16, you must replace `export const revalidate` with the `"use cache"` directive:
34+
35+
```tsx
36+
// ❌ Old (Next.js 15 / incompatible with cacheComponents)
37+
export const revalidate = 3600;
38+
export default async function Page() {
39+
return <div>{new Date().toISOString()}</div>;
40+
}
2041

21-
If upgrading from Next 14 or earlier, **flush your Redis cache** before running new version of the application locally and on your hosted environments. **Cache formats between Next 14 and 15 are incompatible**.
42+
// ✅ New (Next.js 16)
43+
"use cache";
44+
export default async function Page() {
45+
return <div>{new Date().toISOString()}</div>;
46+
}
47+
```
2248

23-
## Next 15 Support
49+
**Important Notes:**
50+
- The custom `cacheHandler` continues to work for ISR, fetch caching, and route handlers
51+
- The new "use cache" directive is managed separately by Next.js and does not use the custom cache handler
52+
- Pages Router (`getStaticProps` with `revalidate`) continues to work unchanged
53+
- Flush your Redis cache when upgrading from Next.js 15 to Next.js 16
2454

25-
The original `@neshca/cache-handler` package does not support Next.js 15.
55+
## Installation
2656

27-
Prior to 2.0.0, this package provided wrappers and enhancements to allow using `@neshca/cache-handler` with Next.js 15.
28-
From version 2.0.0 onward, `@fortedigital/nextjs-cache-handler` is a standalone solution with no dependency on `@neshca/cache-handler` and is fully compatible with Next.js 15 and [redis 5](https://www.npmjs.com/package/redis).
57+
`npm i @fortedigital/nextjs-cache-handler`
58+
59+
If upgrading from Next 14 or earlier, **flush your Redis cache** before running new version of the application locally and on your hosted environments. **Cache formats between Next.js versions may be incompatible**.
60+
61+
## Next.js 16 Support
62+
63+
Version 3.0.0 provides full support for Next.js 16, including:
64+
- ✅ Cache Components and `"use cache"` directive
65+
- ✅ Updated `revalidateTag` API with optional durations parameter
66+
- ✅ Turbopack compatibility
67+
- ✅ Async request APIs (`params`, `searchParams`)
68+
- ✅ ISR and fetch caching (traditional cache handler)
69+
- ✅ Playwright e2e tests for caching behavior
70+
71+
**Configuration for Next.js 16:**
72+
```ts
73+
// next.config.ts
74+
const nextConfig = {
75+
cacheHandler: require.resolve('./cache-handler.mjs'),
76+
cacheMaxMemorySize: 0,
77+
cacheComponents: true, // Enable Cache Components
78+
};
79+
```
2980

30-
We aim to keep up with new Next.js releases and will introduce major changes with appropriate version bumps.
81+
We aim to keep the package version in sync with major Next.js releases and will introduce breaking changes with appropriate version bumps.
3182

3283
### Swapping from `@neshca/cache-handler`
3384

examples/redis-minimal/src/app/static-params-test/[testName]/page copy.tsx

Lines changed: 0 additions & 18 deletions
This file was deleted.

examples/redis-minimal/src/app/static-params-test/[testName]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
"use cache";
2+
13
import React from "react";
24

35
export const dynamicParams = true;
46

5-
export const revalidate = 5;
6-
77
export default async function TestPage({
88
params,
99
}: {

0 commit comments

Comments
 (0)