This blog uses Next.js to create a React blog. It uses Next.js 15 and the new Partial Prerendering to optimize performance and user experience. It connects to the Cosmic API via the Cosmic JavaScript SDK.
git clone https://github.com/cosmicjs/simple-nextjs-blog
cd simple-nextjs-blog
.env.local
file to gain API access to your Cosmic Bucket. To do this, run:cp .env.example .env.local
.env.local
file. It should look something like this:COSMIC_BUCKET_SLUG=your-bucket-slug
COSMIC_READ_KEY=your-bucket-read-key
Install all dependencies and run in development mode.
yarn
yarn dev
Open http://localhost:3000.
Use the following button to deploy to Vercel. You will need to add API accesss keys as environment variables. Find these in Bucket Settings > API Access.