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.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwMTU1NjksIm5iZiI6MTczOTAxNTI2OSwicGF0aCI6Ii8xOTUwNzIyLzM1NzUzNjk2Ny1lNTNlZjFiZS1mNWEzLTRkNWEtOWVhYy00ZGRkNmIzMmNlYzQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDhUMTE0NzQ5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YjI5YmQ0YjQ0N2VlNjE3ZGI4ODY3MDE4NGFjYmMyZGYxNmU0NWQxNDg0ZGQ3OTlhYjdiYTc0ZTIzZWMxMzljMSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.pzShG4P9OrO0BVjFsmAU--v4kS1XG1_LGawcH1u9yaY)
- 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.