N

Next/15/Add-Experimental-Stale-Times

How to Use
Run this codemod on your codebase using one of the following commands

The easiest way to run this codemod without installing anything globally:

Documentation

Configure staleTimes in next.config.js

This guide refactors the next.config.js file to introduce staleTimes configuration options for controlling cache durations of page segments, enhancing caching behavior and performance.

  • Find Configuration Object: Identifies the nextConfig object in the code.

  • Add staleTimes Property: Adds the staleTimes property to the experimental object, specifying cache durations for dynamic and static pages.

  • Specify Cache Durations: Defines the cache duration for dynamic and static pages in seconds.

  • Clean Up: Removes the experimental object if it becomes empty after the migration.

Before

js

After

js

Ready to contribute?

Build your own codemod and share it with the community.