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.
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.
Next.js is a React-based web framework that enables server-side rendering, static site generation, and other powerful features for building modern web applications.
React is a widely used JavaScript library for building user interfaces and single-page applications. It follows a component-based architecture and uses a virtual DOM to efficiently update and render UI components
Apollo is an open-source platform for building GraphQL APIs that connects with any data source. It provides a powerful set of tools and features for developers, including client and server-side caching, real-time data synchronization, and a seamless integration with popular frontend frameworks.
ESLint is a linter for JavaScript that analyzes code to detect and report on potential problems and errors, as well as enforce consistent code style and best practices, helping developers to write cleaner, more maintainable code.
A website that uses GraphQL as a query language to manage data fetching and state management. This includes features such as a strongly typed schema, client-side caching, and declarative data fetching to streamline data management and optimize website performance.
TypeScript is a superset of JavaScript, providing optional static typing, classes, interfaces, and other features that help developers write more maintainable and scalable code. TypeScript's static typing system can catch errors at compile-time, making it easier to build and maintain large applications.