Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
A statically generated blog example using Next.js and the Cosmic headless CMS, with Vercel deployment.
The Next.js Cosmic Blog template is a statically generated blog example from the official Next.js examples collection that pairs the Next.js framework with the Cosmic headless CMS as its data source and supports one-click deployment to Vercel.
It is an official example maintained by the Vercel Next.js team that demonstrates Next.js's Static Generation feature using Cosmic as the content backend. The template takes blog posts stored in a Cosmic bucket — including their slugs, published content, and draft states — and produces a statically generated blog with a post list and individual post pages. It runs on the Next.js framework, has a live demo at https://cosmic-next-blog.vercel.app/, and is packaged as a create-next-app example (alias cms-cosmic).
COSMIC_BUCKET_SLUG, COSMIC_READ_KEY, and COSMIC_PREVIEW_SECRET.[object_slug] shortcode.npx create-next-app --example cms-cosmic cms-cosmic-app, with equivalent Yarn and pnpm commands documented..env.local.example file to copy to .env.local; after npm install and npm run dev, the blog runs at http://localhost:3000.[object_slug] shortcode, then toggle preview mode to see unpublished titles.The README documents six steps: create a Cosmic account and project, install the Next.js Static Blog app from the Cosmic App Marketplace, copy .env.local.example to .env.local and fill in the bucket slug, read key, and preview secret, run npm install and npm run dev, configure the Preview Link under Posts Edit Settings in Cosmic, then deploy to Vercel either by importing the repository or clicking the deploy template button.
Yes. Setup starts by creating an account and a project on Cosmic, then installing the Next.js Static Blog app from the Cosmic App Marketplace. The blog reads posts from a Cosmic bucket through the API using the bucket slug and read key.
Three variables go into .env.local: COSMIC_BUCKET_SLUG and COSMIC_READ_KEY, both found under API Access in Cosmic's Basic Settings, and COSMIC_PREVIEW_SECRET, which can be any random string without spaces and is used for Preview Mode.
In Cosmic's Posts Edit Settings, add a Preview Link such as http://localhost:3000/api/preview?secret=<secret>&slug=[object_slug] using your preview secret. Save a post as a draft without publishing, then open the preview link — the updated draft title appears only in preview mode.
Yes, two paths are documented: push the local project to GitHub, GitLab, or Bitbucket and import it to Vercel while setting the three environment variables, or use the Deploy with Vercel template button, which clones the example and pre-fills the environment variable fields.
The Next.js examples collection lists 28 related blog examples, including AgilityCMS, Builder.io, ButterCMS, Contentful, DatoCMS, Drupal, Ghost, Prismic, Sanity, Storyblok, and WordPress, each pairing the same blog structure with a different content backend.
The same Next.js blog template is available for many other CMSs in the examples collection. Named alternatives include Contentful, Sanity, Storyblok, WordPress, and Ghost, plus the Blog Starter for a setup without a CMS backend.
