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.
![simple-next-blog](https://private-user-images.githubusercontent.com/1950722/357536967-e53ef1be-f5a3-4d5a-9eac-4ddd6b32cec4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyMTE2NTcsIm5iZiI6MTczOTIxMTM1NywicGF0aCI6Ii8xOTUwNzIyLzM1NzUzNjk2Ny1lNTNlZjFiZS1mNWEzLTRkNWEtOWVhYy00ZGRkNmIzMmNlYzQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTBUMTgxNTU3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZDg2OTdmYjJkZDQ3NzI5NGM2YTc5MTk0ZDQ1OTRkNDU5NGNjNWFiZjE1MzlmMjYzMmFiNWMyNTc1ZjJhYjE4NCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.aRdVVesCbuih9y9biC3g-FaPq0w-m5rcAEPeqP8yUEc)
- Log in to Cosmic and install the Simple Next.js Blog template.
- Run the following commands to install the code locally.
git clone https://github.com/cosmicjs/simple-nextjs-blog
cd simple-nextjs-blog
- Create an
.env.local
file to gain API access to your Cosmic Bucket. To do this, run:
cp .env.example .env.local
- Find your API access keys at Bucket Settings > API Access after logging into your Cosmic dashboard and add them to the
.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.