A Next.js boilerplate for decoupled WordPress on VIP.
The Next.js boilerplate for decoupled/ headless WordPress applications is a tool provided by WordPress VIP. It is designed to assist in creating decoupled WordPress sites using Next.js. Although not required for Node.js applications on VIP, this boilerplate helps to solve common use cases for decoupled WordPress applications. It requires the VIP decoupled plugin bundle to be installed and activated on the WordPress backend.
To get started with the Next.js boilerplate, follow these steps:
wp-env using the provided instructions.Note: The boilerplate project does not support plain permalinks.
You can now access the Next.js front-end at http://localhost:3000 and the WordPress backend at http://localhost:8888/wp-admin. Use the default credentials for the admin account.
Update the following environment variables in the .env file:
NEXT_PUBLIC_GRAPHQL_ENDPOINT: The full URL of your WPGraphQL endpoint.NEXT_PUBLIC_SERVER_URL: The full URL of the Next.js site.Add any additional environment variables as needed. The .env.production file contains the working remote environment settings for testing against a live VIP WordPress backend.
Note: The boilerplate project does not support plain permalinks. Refer to the Permalink Setup section for supported configurations.
You should also review the vip.config.js file for additional configuration options.
Start the development server with hot-reloading at http://localhost:3000.
To test your production build locally, use the same commands that will be executed when your application runs on WordPress VIP. The build directory is added to the .gitignore file to avoid build artifacts in the repository. Instead, the build will be automatically run whenever you push code changes.
Preview unpublished posts or updates to published posts by clicking the “Preview” button in the WordPress backend.