- Notifications
You must be signed in to change notification settings - Fork0
chapter-three/next-example-router-migration
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Next.js recommends using their new App Router over the legacy Pages Router. Thefull router migration guide is available in the Next.js documentation.
The new App Router is also designed to facilitate sites that need to migrate from the Pages Router in a piecemeal fashion rather than all at once.
This codebase is an example of anext-drupal site that is in the middle of a Next.js Pages to App Router migration.
- Update the
next-drupalpackage to the latest 2.x version. - Update the
nextmodule on your Drupal site to the latest 2.x version.- The most recent version is available athttps://www.drupal.org/project/next
- Run your Drupal site’s /update.php script.
- Migrate from Preview Mode to Draft mode. Preview mode only works with the legacy Pages Router. Draft mode works with both routers.
- Update the
/pages/api/preview.tsfile to match the one in this Git repo. - Update the
/pages/api/exit-preview.tsfile to match the one in this Git repo. - Delete your
/pages/api/revalidate.tsfile. - Create a
/app/apidirectory and add all the files from this Git repo’s/app/apidirectory.
- Update the
FollowNext.js’ router migration guide.
Over time, you will be moving all the files from/pages to/app. However, these JavaScript files should remain in the/pages directory to prevent Preview/Draft Mode from breaking:
/pages/api/exit-preview.ts/pages/api/preview.ts
- Turn off the legacy Preview Mode.
- Go to the Next.js site configuration on your Drupal site at
/admin/config/services/next. - For each Next.js configuration, change the end of the URL in the “Draft URL (or Preview URL)” setting from
previewtodraft, e.g.https://example.com/api/previewtohttps://example.com/api/draft.
- Go to the Next.js site configuration on your Drupal site at
- Delete the last files in your
/pagesdirectory:/pages/api/exit-preview.ts/pages/api/preview.ts
- Update your
lib/drupal.tsfile and switch from theDrupalClientclass (with dual Pages/App Router support) to the new, leanerNextDrupalclass (with only App Router support).
Licensed under theMIT license.
About
This codebase is an example of a `next-drupal` site that is in the middle of a Next.js Pages to App Router migration.
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.