Giscus is a comment system powered by GitHub Discussions. It allows users to comment using their GitHub accounts and stores discussions in your repository.
Step 1: Create a GitHub Repository
- Go to GitHub and create a new repository (if you don't have one).
- Enable "Discussions" for the repository:
- Navigate to Settings → Features → Enable Discussions.
Step 2: Install Giscus Component in React
yarn add @giscus/react
# or
npm install @giscus/reactStep 3: Configure Giscus
- Go to Giscus setup page.
- Select the repository where discussions will be stored.
- Choose a Discussion Category (e.g.,
Announcements,Q&A). - Choose the Mapping (e.g.,
pathname,title,issue number). - Select a Theme (light, dark, or system preference).
- Copy the configuration settings.
Step 4: Add Giscus Component in React
import React from "react";
import Giscus from "@giscus/react";
const CommentSection = () => {
return (
<Giscus
id="comments"
repo="your-github-username/your-repository"
repoId="your-repo-id"
category="Announcements"
categoryId="your-category-id"
mapping="pathname"
reactionsEnabled="1"
emitMetadata="0"
theme="light"
lang="en"
/>
);
};
export default CommentSection;Replace:
repo="your-github-username/your-repository"repoId="your-repo-id"category="your-category"categoryId="your-category-id"
(You can find these values in the Giscus app settings you copied earlier.)
Step 5: Add Component in the Page
import CommentSection from "./CommentSection";
function App() {
return (
<div>
<h1>My Blog Post</h1>
<p>This is my blog content...</p>
<CommentSection />
</div>
);
}
export default App;Step 6: Test the Comment Box
npm startNavigate to the page where you added the Giscus component, log in with GitHub, and post a test comment.
Step 7: Deploy Your React App
Once your React app is working locally, deploy it using:
- Vercel: vercel.com
- Netlify: netlify.com
- GitHub Pages
- Custom server (e.g., Docker, AWS, Railway, etc.)
Bonus: Customizing Giscus
You can customize:
- Themes (
light,dark,preferred_color_scheme) - Reaction Emojis (
1to enable,0to disable) - Metadata Emission (
1to enable,0to disable) - Language (e.g.,
en,fr,de)
<Giscus
theme="preferred_color_scheme"
reactionsEnabled="1"
lang="en"
/>🎉 Done! Now your React app has a fully functional GitHub-based comment system! 🚀