• Stars
    star
    108
  • Rank 321,259 (Top 7 %)
  • Language
    JavaScript
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Next.js powered blog with DatoCMS integration

A Blog example using Next.js and DatoCMS

This example showcases a Next.js Blog using DatoCMS as the data source. It fully supports Preview Mode with DatoCMS real-time updates.

The purpose of this repo is to have a quick start reference that can be set up with the "one-click" button below.

Demo

Have a look at the end result live:

https://nextjs-demo-bay.vercel.app/

How to use

Quick start

  1. Create an account on DatoCMS.

  2. Make sure that you have set up the Github integration on Vercel.

  3. Let DatoCMS set everything up for you clicking this button:

Deploy with DatoCMS

Local setup

Once the setup of the project and repo is done, clone the repo locally.

Set up environment variables

In your DatoCMS' project, go to the Settings menu at the top and click API tokens.

Then click Read-only API token and copy the token.

Next, copy the .env.example file in this directory to .env (which will be ignored by Git):

cp .env.example .env

Then set each variable on .env:

Your .env file should look like this:

NEXT_DATOCMS_API_TOKEN=...
NEXT_DATOCMS_PREVIEW_SECRET=...

Run your project locally

npm install
npm run dev

Your blog should be up and running on http://localhost:3000!

Try preview mode

On DatoCMS, go to one of the posts you've created and:

  • Update the title. For example, you can add [Draft] in front of the title.
  • Click Save, but DO NOT click Publish. By doing this, the post will be in the draft state.

(If it doesn't become draft, you need to go to the model settings for Post, go to Additional Settings, and turn on Enable draft/published system.)

Now, if you go to the post page on localhost, you won't see the updated title. However, if you use the Preview Mode, you'll be able to see the change (Documentation).

To enable the Preview Mode, go to this URL:

http://localhost:3000/api/draft?secret=<secret>
  • <secret> should be the string you entered for NEXT_DATOCMS_PREVIEW_SECRET.
  • <slug> should be the post's slug attribute (you can check on DatoCMS).

You should now be able to see the updated title. To exit the preview mode, you can click Click here to exit preview mode at the top.

More Repositories

1

react-datocms

A set of components and utilities to work faster with DatoCMS in React environments
TypeScript
165
star
2

new-website

Next.js project powering our marketing page!
JavaScript
141
star
3

gatsby-source-datocms

Official GatsbyJS source plugin to pull content from DatoCMS
JavaScript
140
star
4

gatsby-portfolio

Sample DatoCMS website built with GatsbyJS
Sass
116
star
5

js-datocms-client

NodeJS/Browser client for DatoCMS
JavaScript
72
star
6

plugins

Repository providing samples using the Plugins SDK
TypeScript
30
star
7

vue-datocms

Vue.js components for DatoCMS
TypeScript
24
star
8

middleman-dato

A Middleman extension to integrate your website with DatoCMS
Ruby
24
star
9

structured-text

TypeScript
22
star
10

ruby-datocms-client

Ruby client for the DatoCMS API.
Ruby
20
star
11

product-roadmap

This project is now discontinued. For feature requests, please use our community forum.
19
star
12

snipcart-gatsby-demo

Simple e-commerce for socks made with Gatsby, Snipcart and DatoCMS
SCSS
14
star
13

next-event-coverage-liveblog

A Next.js project demonstrating the use of DatoCMS Real-time Updates API.
JavaScript
13
star
14

gatsby-example

JavaScript
12
star
15

hugo-example

Example project with DatoCMS and Hugo
HTML
12
star
16

nuxtjs-demo

DatoCMS + Nuxt.js + Bulma blog demo
Vue
11
star
17

datocms-svelte

The DatoCMS library for Svelte
TypeScript
9
star
18

translations

Translations for our CMS interface
JavaScript
9
star
19

datocms-listen

A lightweight, TypeScript-ready package that offers utilities to work with DatoCMS Real-time Updates API inside a browser.
TypeScript
9
star
20

next-landing-page-demo

TypeScript
9
star
21

middleman-example

Middleman demo for DatoCMS
SCSS
8
star
22

sveltekit-demo

SvelteKit powered blog with DatoCMS integration
Svelte
7
star
23

js-rest-api-clients

REST API clients to interact with DatoCMS
TypeScript
7
star
24

remix-example

JavaScript
6
star
25

old-website

JavaScript
6
star
26

plugins-sdk

An SDK to customize the functionality of the DatoCMS webapp.
TypeScript
6
star
27

next-minimalistic-photography

TypeScript
5
star
28

jekyll-portfolio

Example portfolio built with Jekyll and DatoCMS
Sass
5
star
29

gatsby-blog-demo

JavaScript
5
star
30

metalsmith-portfolio

JavaScript
5
star
31

datocms-astro-blog-demo

Astro
5
star
32

hexo-example

HTML
5
star
33

vuejs-demo

Vue.js + DatoCMS profile card demo
Vue
5
star
34

hugo-portfolio

Example portfolio built with Hugo and DatoCMS
Sass
4
star
35

cli

Official CLI to interact with DatoCMS projects!
TypeScript
4
star
36

nextjs-demo-i18n

Simple multi-language blog built with Next.js and DatoCMS, with real-time updates in preview mode
JavaScript
4
star
37

react-native-demo

JavaScript
4
star
38

datocms-search

The search widget powered by DatoCMS
JavaScript
4
star
39

typescript-type-generation-graphql-example

TypeScript
4
star
40

jekyll-example

Example project with DatoCMS and Hugo
HTML
3
star
41

documentation

HTML
3
star
42

gatsby-remark-images-datocms

Processes images in markdown coming from DatoCMS so they can be used in the production build using DatoCMS's built-in CDN.
JavaScript
3
star
43

react-graphql-demo

DatoCMS Demo project React + GraphQL Request
JavaScript
2
star
44

next.js-i18n-blog-demo-with-per-locale-publication

JavaScript
2
star
45

next.js-i18n-blog-demo-site-search

JavaScript
2
star
46

nextjs-datocms-demo-preact

JavaScript
2
star
47

react-urql-demo

A demo project with DatoCMS and URQL
JavaScript
2
star
48

og-image

TypeScript
2
star
49

react-demo

Airbnb clone - React & GraphQL demo using DatoCMS
SCSS
2
star
50

metalsmith-example

HTML
2
star
51

fast_thumbhash

A highly optimized implementation of the ThumbHash algorithm, a compact representation of an image placeholder for a smoother loading experience
C
2
star
52

structured-text-migration-example

Some sample migrations to convert HTML/Markdown/Modular content fields into Structured Text
TypeScript
1
star
53

express-demo

CSS
1
star
54

hexo-portfolio

CSS
1
star
55

generator-datocms-plugin

JavaScript
1
star
56

php-demo

Twig
1
star
57

status-website

JavaScript
1
star
58

middleman-portfolio

DatoCMS + Middleman example portfolio
Sass
1
star
59

react-apollo-demo

DatoCMS Demo project React + Apollo
JavaScript
1
star