To self-host giscus, you need to create a new GitHub App and deploy the web app. You can use this guide as a reference.
- Create a new GitHub App
- Generate a private key
- Generate a client secret
- Copy App ID and Client ID
- Install the app
- Configure Supabase for caching access tokens (optional)
- Deploy giscus
- Use the deployed self-hosted giscus
- Go to the GitHub App creation page.
-
- Feel free to name it whatever you want (e.g.
myblog-comments
). I would appreciate it if you indicate that it is a self-hosted version of giscus (with the link) in the description. - Use
https://giscus.app
as the homepage URL unless you also accept any users to use your service on their repositories.
- Feel free to name it whatever you want (e.g.
-
-
Use
https://[YOUR-DOMAIN-HERE]/api/oauth/authorized
as the authorization callback URL, e.g.https://giscus.app/api/oauth/authorized
. -
Do not check "Expire user authorization tokens", as giscus currently does not support it.
You can change
TOKEN_VALIDITY_PERIOD
in the code instead, which will automatically revoke user tokens and sign them out after that period. -
Do not check "Request user authorization (OAuth) during installation".
-
-
- Enable "Read & write" access for "Discussions". This is the only permission that you need, leave everything else as-is.
-
- You don't need to change anything in this section. Leave "Where can this GitHub App be installed?" set to "Only on this account", unless you also accept any users to use your service on their repositories.
-
- Upon registration, you will need to create a private key in order to install the app.
-
- Click the button.
-
- The private key will be downloaded to your device.
-
- Click the "Generate a new client secret" button.
-
- Copy your client secret and store it somewhere safe.
-
- Click on the "Install App" sidebar menu and click on the "Install" button on your account.
-
-
Choose "Only select repositories" and select the repositories where giscus will be installed on.
Alternatively, you can choose "All repositories". However, note that this will grant the app access to all of your repositories' discussions, including private ones. This also means that anyone can use the app to read and post any discussions in your repositories, as long as they know the repository names.
-
-
- Click the button.
GitHub App installation access tokens have a 60 minute TTL. You can configure giscus to cache the tokens in a Supabase table. This reduces the number of token requests to GitHub, which helps prevent the app from hitting the rate limit.
- Log in to Supabase.
- Create a new project.
- Create a new table within the project. The table name can be arbitrary, but
giscus uses
installation_access_tokens
as the default. - Use the following schema for the table:
installation_id: int8, no default value, primary key, uncheck Is Identity token: varchar, no default value expires_at: timestamptz, no default value created_at: timestamptz, default value NOW() updated_at: timestamptz, default value NOW() None of the columns are nullable (uncheck Is Nullable via the gear icon). Only installation_id is the primary key.
- Take note of your Supabase project's URL (
https://xxxxx.supabase.co
) and your API key. - Make sure that you either:
- Disable Row Level Security (RLS) on the table, or
- Use the secret
service_role
API key.
The giscus.app website is hosted on Vercel, but you can deploy it anywhere that can run a Next.js application and its serverless functions.
-
Clone the repository.
-
Generate a random string with a reasonable length (e.g. 64 characters) that will be used to encrypt the user token.
-
Set the example environment variables in your deployment and change the values accordingly. On a server, you can put them in a
.env.local
file and Next.js will automatically pick it up. -
Install the dependencies.
yarn install
-
Build the application.
yarn build
-
Start the server.
yarn start
- You can use the main page of the website to generate the client script
configurations (e.g.
data-repo-id
,data-category-id
) just like on giscus.app. - Include the script tag to your webpage. Make sure you use the client script that is hosted from your deployment.
If you have any questions, ask them on the Q&A discussion. If you encounter any problems, create a new issue.