Skip to content

jmfirth-arkane/kontent-ai-next-js-boilerplate

Repository files navigation

A Statically generated page using Next.js and Kontent

Netlify Status

Stack Overflow Discord

This boilerplate showcases Next.js's Static Generation feature using Kontent.ai as the data source.

Screenshot

Demo

Getting Started

Deploy

Deploy with Vercel

Deploy on Netlify

Init project by command line

Execute create-next-app with npm or Yarn to bootstrap the example:

npx create-next-app --example https://github.com/kontent-ai/boilerplate-next-js kontent-boilerplate-next-js
# or
yarn create next-app --example https://github.com/kontent-ai/boilerplate-next-js kontent-boilerplate-next-js

Code development

Environment variables

  1. Set up environment variables

    • Copy the .env.local.template file in this directory to .env.local (which will be ignored by Git):

      cp .env.local.template .env.local
  2. Run the development server:

    npm run dev
    # or
    yarn dev

🎉 Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying pages/index.js. The page auto-updates as you edit the file.

By default, the content is loaded from a shared Kontent.ai project. If you want to use your own clone of the project so that you can customize it and experiment with Kontent, continue to the next section.

Create your own data source project in Kontent.ai

Create Kontent.ai project

To generate the clone of the sample project in order to be able to edit the content, use Sample site generator - use "CREATE A NEW SAMPLE PROJECT" for generating the project.

Connect Kontent.ai project with code base

  1. Access the project listing on Kontent.ai application.
  2. Select newly generated project (its name is about to be Sample Project M/DD/YYYY, H:MM:SS AM/PM).
  3. Set env variables on .env.local:
    • KONTENT_PROJECT_ID - Should be the Project ID in Project settings > API keys.

Content editing development

Run the development server:

npm run dev
# or
yarn dev

🎉 Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying content in Kontent.ai project. The page auto-updates as you edit the content, you just need to publish the changes.

Preview

Next.js offers embedded possibility to preview unpublished content - the preview mode. If you want to include this capability - follow the linked guide, or jum straight to the Kontent.ai example that already includes implementation of the preview and exit-preview API route.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Related content

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published