Skip to content

Support Next.js 16 in next/server and move next-app to it - #12

Merged
javaquasar merged 2 commits into
mainfrom
claude/next-16-examples
Dec 3, 2026
Merged

javaquasar merged 2 commits into
mainfrom
claude/next-16-examples

Conversation

@javaquasar

Copy link
Copy Markdown
Owner

Summary

mutaflow@0.2.0 does not work cleanly with Next.js 16. Next.js 16 requires the second argument of revalidateTag (a cacheLife profile) and deprecates calls without it:

  • passing Next.js 16's revalidateTag to withFlowContract or createNextServerHelpers is a type error;
  • at runtime, every call logs "revalidateTag" without the second argument is now deprecated, because mutaflow passed no profile unless the strategy was stale-while-revalidate.

This PR fixes mutaflow/next/server and moves examples/next-app to Next.js 16.

Library (packages/mutaflow/src/next/server/index.ts):

  • NextCacheBindings.revalidateTag takes profile: NextRevalidateTagProfile (string | { expire?: number }), so the revalidateTag of both Next.js 15 and Next.js 16 fits.

  • A profile is always passed:

    • "max" for stale-while-revalidate, as before;
    • { expire: 0 } otherwise. That expires the tag now, which is what the one-argument call did.

    Next.js 15's revalidateTag(tag) ignores the extra argument; I checked the 15.5.29 source.

  • A new revalidateProfile option in withFlowContract and applyNextInvalidations overrides the profile. NextRevalidateTagProfile is exported from mutaflow/next/server.

Examples:

  • examples/next-app moves to next ^16.5.0 and passes updateTag, so consistency.immediate uses it for read-your-own-writes.
  • examples/published-next-app stays on Next.js 15. It installs mutaflow@0.2.0 from npm, which has the type error above, so its CI job would fail on Next.js 16. Its README says why. It can move once a release with this fix is published.
  • The READMEs note that updateTag exists from Next.js 16, and CHANGELOG.md gets an Unreleased section.

This branch is based on #11. Merge #11 first; after that, the diff here contains only commit 7c08111.

Test plan

  • New runtime test with a revalidateTag shaped like Next.js 16 (it throws without a profile). It covers the stale-while-revalidate, immediate-without-updateTag and revalidateProfile cases.
  • New type test tests/types/next-cache.ts: the Next.js 15 and 16 next/cache signatures fit NextCacheBindings, and a narrower revalidateTag does not.
  • From clean installs:
    • at the root, npm run typecheck and npm test pass (63 tests, plus 5 node:test tests);
    • examples/next-app (Next.js 16.5) and examples/published-next-app (Next.js 15.5) pass npm ci, typecheck and next build.
  • next-app typechecks with no .next folder, as in CI.
  • In the browser on next start with Next.js 16:
    • a new todo shows right after the action without a reload and persists after one;
    • a duplicate shows a field error;
    • the server log shows the tags under updatedTags and nothing under revalidatedTags;
    • there is no deprecation warning and no console errors.
  • CI passes on this PR.

🤖 Generated with Claude Code

Artur Buzov and others added 2 commits December 3, 2026 00:18
examples/published-next-app now locks mutaflow and @mutaflow/devtools
0.2.0 from npm, and a new CI job installs, typechecks and builds it
without the workspace, so the install path of the latest release is
checked on every change.

Each package's build removes dist first, so files from an older build
of another branch cannot end up in a published tarball. The root clean
script uses Node instead of PowerShell.

npm audit fix (no major upgrades) updates jsdom's undici and
source-map-js at the root and next 15.5.29, nanoid and sharp in the
examples. postcss inside Next 15 still needs Next 16.

RELEASING.md notes how to check npm ownership before publishing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Next.js 16 requires the profile argument of revalidateTag and
deprecates calls without it. With 0.2.0, passing its revalidateTag to
withFlowContract was a type error, and every call logged a warning.

NextCacheBindings.revalidateTag now takes a NextRevalidateTagProfile,
so the functions of both Next.js 15 and 16 fit. A profile is always
passed: "max" for stale-while-revalidate, { expire: 0 } otherwise
(expire now, as before); Next.js 15 ignores it. revalidateProfile in
the options overrides it.

examples/next-app moves to Next.js 16 and passes updateTag, so
consistency.immediate uses it; npm audit is clean there.
examples/published-next-app stays on Next.js 15 until a release with
this fix is on npm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@javaquasar
javaquasar merged commit c2c4b2f into main Dec 3, 2026
5 checks passed
@javaquasar javaquasar mentioned this pull request Dec 3, 2026
4 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant