Update Route Handlers to Handle Caching in Next15 #1299
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📚 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.
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.
Apply the codemod to the repository available at
(https://github.com/imbhargav5/nextbase-nextjs-supabase-starter) and (https://github.com/nisabmohd/ChatGPT)
Could you confirm that all GET functions are updated to include the dynamic configuration for caching?
Test the application to ensure it functions correctly with the updated caching settings.
All other test cases are run in the codemod studio and are present in
/codemod/packages/codemods/next/15/route-handler-caching/textfixtures/.
📄 Documentation to Update