jakala-na / next-contentful-starterkit

https://next-contentful-starterkit.vercel.app/
MIT License
2 stars 0 forks source link

Next.js Contentful Starterkit

This starterkit is meant to provide a good mix of best practices for working with Contentful in Next.js. It doesn't pretend to be the only way, but it is meant to address the main painpoints concerning data-fetching, component resolution, live previews, configuration management and App development. We believe a good starterkit is use-case based, but there is no good way to model all use-cases in same starter, so while we're starting as a marketing site, it may evolve later. In fact, it is modeled around Contentful's own Marketing Template content model, with a slight twist on the content part.

The starterkit's cornerstone is our data-fetching solution and it's typesafety. The goal is to have best-in-class Typescript-enabled, graphql-powered data fetching to eliminate guessing games in our components and provide full type definitions for free. The list of current features with descriptions can be found below.

Features

Getting Started

  1. This project is a template, feel free to either clone it (to preserve project history) or use click "Use this template" to create a repository with a single init commit. As soon as you have a repository, clone it locally
  2. Install dependencies with:
yarn install
  1. Setup Contenful access To develop locally, you will want to connect to a Contentful instance that has the same data model as we use to develop, there are 3 ways to do that:

You will want to get a CDA and CPA API keys by using this guide

  1. Configure environment

Create .env.local in root directory of the repo with the following contents:

CONTENTFUL_SPACE=<space id>
CONTENTFUL_DELIVERY_API=<delivery api key>
CONTENTFUL_PREVIEW_API=<preview api key>
CONTENTFUL_ENVIRONMENT=master
CONTENTFUL_PREVIEW_SECRET=secret
# Enable or disable Content Source Maps, see https://www.contentful.com/developers/docs/tools/vercel/content-source-maps-with-vercel/
CONTENTFUL_USE_CONTENT_SOURCE_MAPS=true
  1. Run Dev Server
yarn dev

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

Documentation

Deploy to Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

Support

While this starterkit is in active development, fixing some UI bugs or unfinished components may not be a priority.

This starterkit is meant to serve two purposes:

  1. Provide best practices for starting new projects with Contentful and Next.js
  2. Provide a demo site and a playground to test new features released in Next.js and Contenful

You are free to use the starterkit as a template to start new projects, but you can also pick and choose which reference implementations you like and copy them into your own project.

The demo site will evolve as we strive to demostrate more Next.js capabilities, but so will the Contentful part as Contentful adds more features (Contentful Studio, Taxonomy, etc)

Some features are going to be implemented just enough to demonstrate the concept in a demo, other features may be relying on particular infrastructure like on Vercel, it will be a balancing act.

Our commitment is to support majority of users and let them opt in, remove or modify certain functionality if they don't share the same infrastructure or feature set. We will provide documentation and guidance how to do that

Contributors

This project is open-source under MIT license and accepts contributions, if you have any feedback, please create a discussion or an issue on Github.