Create Next.js project
Create a new Next.js project using the starter
Now that we have completed the Drupal configuration, we can create our Next.js project.
We are going to use the GraphQL starter.
Create Project
Run the following command to create a new Next.js project:
npx create-next-app -e https://github.com/chapter-three/next-drupal-graphql-starter
Connect Drupal
To connect the Next.js project to Drupal, we use environment variables.
- Copy
.env.example
to.env.local
. - Fill in the following Environment variables:
.env.local
NEXT_PUBLIC_DRUPAL_BASE_URL=http://example.comNEXT_IMAGE_DOMAIN=example
# AuthenticationDRUPAL_CLIENT_ID=DRUPAL_CLIENT_SECRET=
Start Development Server
To start the Next.js development server, run npm run dev
or yarn dev
. This starts the development server on http://localhost:3000
.
Visit http://localhost:3000 to view the site.