Ask
23
@gitreflog_saved ·

How do I get back off next@preview to a stable Next.js after trying Cache Components?

I installed next@preview to try the instant navigation work, turned on cacheComponents: true, sprinkled 'use cache' through layouts and data loaders, and now my i18n and auth paths are unhappy in ways I do not want to fix at 11pm.

I want to go back to a stable release with the least drama. Specifically:

  • if I turn cacheComponents off, do the 'use cache' directives I added become harmless, or do I have to remove every one of them?
  • what is the right order of operations so I do not end up with a lockfile that still resolves to the preview build?
  • how do people stop dist-tags like preview and latest from silently moving under them again next month?

Monorepo, npm, App Router, TypeScript, if it matters.

6 answers Share
Report

Answering anonymously — a moderator will review it first.

  • @coldstorage_cy · 2h ago · 2 replies

    Order that works:

    1. Pin an exact version in package.json. Not preview, not latest, not ^. A literal version string.
    2. Delete node_modules and .next. The build cache will happily hand you artifacts from the previous version and you will spend an hour debugging a ghost.
    3. Reinstall, then verify what you actually got: npm ls next and the version your dev server prints on boot. Do not trust package.json, trust the resolved tree.
    4. Only then start reverting code.

    Step 3 is the one people skip, and it is exactly how you end up insisting you are on stable while still running the preview build.

    19
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
    • @schema_drift_lu · 10h ago

      In a monorepo also grep for an overrides/resolutions entry at the root, and check the sibling packages: eslint-config-next and anything under @next/* need to move with the framework. A stale @next/* at a preview version against a stable core is a great source of errors that look like your code and are not.

      7
      Share
      Reply

      Answering anonymously — a moderator will review it first.

      Report
  • @etcd_eli · 2h ago

    On the directive question: use cache is a Cache Components feature and is enabled by the cacheComponents flag, per the docs and the version history (it arrived with 16.0, having been experimental in 15). So the directives are not a general-purpose annotation you should expect to be inert with the flag off.

    The clean move is not to reason about it at all: revert the commits that added them. If you did the experiment on main, git revert the range, or cherry-pick the two or three changes worth keeping onto a fresh branch.

    Honest limit on that answer: I removed mine rather than test what a build does when the directives are left in place with the flag off. If you try it, post what happened, because that is the thing everyone wants to know and nobody documents.

    14
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
  • @rust_rescue_rin · 2h ago

    The framework rollback is the easy half. What costs you the day is the code shape you adopted for it: components split for streaming, loaders restructured to take values as arguments, data moved out of layouts.

    So next time, and there will be a next time: preview channel on its own branch, its own preview deployment, lockfile committed, and a note in the PR listing every config flag you flipped. Then a rollback is one revert plus one install, instead of an archaeology session.

    9
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
  • @egress_egon · 2h ago · 2 replies

    Ask whether you need to roll back at all. use cache and cacheComponents have been part of the stable 16 line since 16.0. The preview channel is where the newer navigation work lives.

    If what broke your app was the i18n/auth interaction with caching, dropping to the preview build's predecessor on the stable line keeps your caching work and removes the moving target. If what you actually wanted was the new navigation behaviour specifically, then yes, you are choosing between that and a quiet week.

    6
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
    • @goroutine_gil · 2h ago

      With one caveat: strip anything you copied from the preview documentation first. The preview-only pieces, the dev panel and the per-route opt-out it suggests, are not part of the stable release, and leaving a route-level export in place that stable does not recognise is a confusing 20 minutes.

      5
      Share
      Reply

      Answering anonymously — a moderator will review it first.

      Report