Setting Up Giscus Comments in Next.js (GitHub Discussions)
Setting Up Giscus Comments in Next.js (GitHub Discussions)
Add a zero-database, markdown-ready comment system to your Next.js blog using Giscus and GitHub Discussions, with…
·Updated on:··
⚡ Next.js Implementation Guides
In-depth Next.js guides covering App Router, RSC, ISR, and deployment. Get code examples, optimization checklists, and prompts to accelerate development.
In this guide, you will learn how to add a comments system to your Next.js blog or website using Giscus. (If you prefer storing comments directly in your CMS without requiring readers to sign in with GitHub, check out my custom Next.js + Sanity commenting system.) By the end of this tutorial, you'll be able to:
Enable GitHub Discussions on your repository
Install and configure the Giscus app
Implement a comments component in your Next.js application
Handle light/dark mode theming
Troubleshoot common issues
Giscus is a comments system powered by GitHub Discussions, which means all comments are stored as GitHub Discussion comments. This approach has several advantages:
No database required: Comments are stored in GitHub
Free hosting: No additional costs for comment storage
Markdown support: Full markdown formatting in comments
GitHub authentication: Users sign in with their GitHub accounts
Moderation tools: Moderate comments directly through GitHub
Prerequisites
A GitHub repository for your project
A Next.js application
Basic knowledge of React and TypeScript
Step 1: Enable GitHub Discussions
Before you can use Giscus, you need to enable GitHub Discussions on your repository:
Go to your GitHub repository
Click on the "Settings" tab
Scroll down to the "Features" section
Check the box next to "Discussions"
Click "Set up discussions"
Configure the discussion categories (make sure to have an "Announcements" category)
GitHub Discussions Setup
Step 2: Install the Giscus App
Next, you need to install the Giscus app on your repository: