Welcome to this project showcasing how to use PMKIN, a headless CMS, with Next.js (App Router). This example demonstrates building a simple blog application.
Check out the live demo: https://pmkin-next-js-app-router-quick-start.vercel.app/
This project demonstrates:
- Using PMKIN as a content backend
- Setting up Next.js with the App Router
- Querying PMKIN using GraphQL via Apollo Client
- Rendering markdown content with react-markdown
-
Clone the repository:
git clone https://github.com/pmkin-cms/pmkin-next-js-app-router-quick-start.git -
Install dependencies:
cd pmkin-nextjs-example yarn -
Create a
.env.localfile and add your PMKIN API key:PMKIN_API_KEY=your_api_key_here -
Start the development server:
yarn dev -
Open http://localhost:3000 in your browser to see the result.
app/page.tsx: The home page that fetches and lists blog posts.app/posts/[slug]/page.tsx: Handles individual blog post pages, fetching and rendering post content.lib/apollo-client.ts: Sets up Apollo Client for GraphQL queries to PMKIN's API.
Feel free to modify this example to fit your needs. You can add styling, incorporate additional features, or adapt it to your specific use case.
For more information on how to use PMKIN with Next.js, check out the PMKIN documentation.
If you have any questions or run into issues, please create an issue in this repository.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Happy coding!