Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Route Handlers to Handle Caching in Next15 #1299

Closed
wants to merge 8 commits into from

Conversation

nishant2253
Copy link

📚 Description

This codemod refactors Route Handler files to manage caching behavior for GET functions. In the updated setup, GET methods are no longer cached by default. This codemod updates your Route Handler files to specify caching by adding the dynamic configuration option to routes requiring caching.

  1. Find Route Handlers: Identifies all GET functions in the Route Handler files.
  2. Property Check: Ensures the presence of GET functions and adds the dynamic configuration option where necessary.
  3. Add Caching Configuration: Inserts export const dynamic = 'force-static'; to enable caching for GET methods.
  4. Clean Up: Removes the experimental object if it is empty after the migration.

To run this codemod, run the following command in the project directory:
codemod Next/15/Update-Route-Handlers

🧪 Test Plan

Test the codemod by applying it to a specified repository to ensure that Route Handler files are updated correctly with the caching configuration. Verify that GET functions are correctly modified to include export const dynamic = 'force-static'; where needed and that there are no caching errors in the application.

📄 Documentation to Update

  • If applicable, update any relevant documentation to reflect changes in the caching behavior for GET functions. This may include README files or other developer guides that reference Route Handler caching strategies.

Copy link

vercel bot commented Aug 30, 2024

@nishant2253 is attempting to deploy a commit to the Codemod Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Aug 30, 2024

CLA assistant check
All committers have signed the CLA.

@mohab-sameh
Copy link
Contributor

merge into one PR

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.

3 participants