Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
G

gitalk

> 前端框架
Open source

Gitalk is a modern comment component based on Github Issue and Preact.

7.2K stars0 likes2 views
WebsiteGitHub

About

Gitalk is a modern comment component based on Github Issue and Preact.

Gitalk

NPM CDNJS david-dm travis coveralls gzip-size

Gitalk is a modern comment component based on GitHub Issue and Preact.

Features

  • Authentication with github account
  • Serverless, all comments will be stored as github issues
  • Both personal and organization github projects can be used to store comments
  • Localization, support multiple languages [en, zh-CN, zh-TW, es-ES, fr, ru, de, pl, ko, fa, ja]
  • Facebook-like distraction free mode (Can be enabled via the distractionFreeMode option)
  • Hotkey submit comment (cmd|ctrl + enter)

中文说明 Demo

Install

Two ways.

  • links
xml
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">
  <script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>

  

  <link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css">
  <script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
  • npm install
bash
npm i --save gitalk
javascript
import 'gitalk/dist/gitalk.css'
import Gitalk from 'gitalk'

Usage

Firstly, you need choose a public github repository (existed or create a new one) for store comments,

Then create A GitHub Application if you don't have one, Click here to register a new one. Note: You must specify the website domain url in the Authorization callback URL field.

Lastly, you can choose how to apply to the page as below:

Method One

Add a container to your page:

xml

Then use the Javascript code below to generate the gitalk plugin:

javascript
const gitalk = new Gitalk({
  clientID: 'GitHub Application Client ID',
  clientSecret: 'GitHub Application Client Secret',
  repo: 'GitHub repo',      // The repository of store comments,
  owner: 'GitHub repo owner',
  admin: ['GitHub repo owner and collaborators, only these guys can initialize github issues'],
  id: location.pathname,      // Ensure uniqueness and length less than 50
  distractionFreeMode: false  // Facebook-like distraction free mode
})

gitalk.render('gitalk-container')

Method Two: Use in React

Import the Gitalk with

javascript
import GitalkComponent from "gitalk/dist/gitalk-component";

And use the component like

javascript
<GitalkComponent options={{
  clientID: "...",
  // ...
  // options below
}} />

Options

  • clientID String

    Required. GitHub Application Client ID.

  • clientSecret String

    Required. GitHub Application Client Secret.

  • repo String

    Required. GitHub repository.

  • owner String

    Required. GitHub repository owner. Can be personal user or organization.

  • admin Array

    Required. GitHub repository owner and collaborators. (Users who having write access to this repository)

  • id String

    Default: location.href.

    The unique id of the page. Length must less than 50.

    Note: You can use regex to extract certain path of the URL as the id. E.g., location.href.match('/(?<=posts/)(.*)(?=/)/')[1]

  • number Number

    Default: -1.

    The issue ID of the page, if the number attribute is not defined, issue will be located using id.

  • labels Array

    Default: ['Gitalk'].

    GitHub issue labels.

  • title String

    Default: document.title.

    GitHub issue title.

  • body String

    Default: location.href + header.meta[description].

    GitHub issue body.

  • language String

    Default: navigator.language || navigator.userLanguage.

    Localization language key, support [en, zh-CN, zh-TW, es-ES, fr, ru, de, pl, ko, fa, ja].

  • perPage Number

    Default: 10.

    Pagination size, with maximum 100.

  • distractionFreeMode Boolean

    Default: false.

    Facebook-like distraction free mode.

  • pagerDirection String

    Default: 'last'

    Comment sorting direction, available values are last and first.

  • createIssueManually Boolean

    Default: false.

    By default, Gitalk will create a corresponding github issue for your every single page automatically when the logined user is belong to the admin users. You can create it manually by setting this option to true.

  • proxy String

    Default: https://cors-anywhere.azm.workers.dev/https://github.com/login/oauth/access_token.

    GitHub oauth request reverse proxy for CORS. Why need this?

  • flipMoveOptions Object

    Default:

    javascript
      {
        staggerDelayBy: 150,
        appearAnimation: 'accordionVertical',
        enterAnimation: 'accordionVertical',
        leaveAnimation: 'accordionVertical',
      }

    Comment list animation. Reference

  • enableHotKey Boolean

    Default: true.

    Enable hot key (cmd|ctrl + enter) submit comment.

Instance Methods

  • render(String/HTMLElement)

    Init render and mount plugin.

TypeScript

TypeScript definitions for options and Gitalk class come with the package and should be automatically detected.

Definitions for React component usage are not included.

Contributing

  1. Fork the repository and create your branch from master
  2. If you've added code that should be tested, add tests!
  3. If you've changed APIs, update the documentation.
  4. Ensure the test suite passes (npm test).
  5. Make sure your code lints (npm run lint).
  6. Commit your changes (git commit) Commit Message Format Reference

Similar Projects

  • gitment
  • vssue

LICENSE

MIT

Issues· 155 open

View all issuesOpen on GitHub
  • #595

    Ho

    Updated Apr 8, 2026
  • #580

    無法使用呀

    Updated Nov 8, 2025
  • #576

    部署到hexo后显示Be careful! The redirect_uri is not associated with this application. The application might be misconfigured or could be trying to redirect you to a website you weren't expecting.

    Updated Sep 26, 2025
  • #593

    [建议] 更新依赖包[email protected], [email protected]

    Updated Sep 23, 2025
  • #592

    The redirect_uri is not associated with this application.

    Updated Sep 17, 2025
  • #591

    新手该如何使用github

    Updated Sep 10, 2025
  • #588

    本地通过调用 github api create issue 成功,非 admin 账号或非登录用户打开文章页,仍然显示 未找到相关的 Issues

    Updated Aug 1, 2025
  • #579

    `findDOMNode` is removed in React 19, causing runtime error

    Updated Jul 14, 2025
  • #542

    npm install出错

    Updated Jun 16, 2025
  • #453

    【功能建议】配置 Gitalk 主题颜色

    enhancementUpdated Apr 19, 2025

> Tags

JavaScriptcommentgithubgithub-issuesplugin

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 22, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架