Skip to content

Custom hooks to make utterances available in React apps

Notifications You must be signed in to change notification settings

yamauz/use-utterances-ref

Repository files navigation

useUtterancesRef

A custom hook to make utterances available in React apps

⚠️ ️You must install the GitHub Apps for utterances from here before using this library.

Installation

With npm

npm i use-utterances-ref

With yarn

yarn add use-utterances-ref

Usage

import { useUtterancesRef } from "use-utterances-ref";

const ref = useUtterancesRef<HTMLDivElement>("user/public-repo");

return <div ref={ref} />;

API

useUtterancesRef(repository_name, options);

Arguments

repository_name

A public GitHub repository. This is where the blog post issues and issue-comments will be posted.

Required. Set like "owner/repo"

options

All options is optional. See here for more details on options.

Key Type Default Description
issueTerm "pathname" | "url" | "title" | "og:title" | string "pathname" The mapping between blog posts and GitHub issues.
issueNumber string If issueTerm is set, it is invalid.
label string The label that will be assigned to issues created by Utterances.
theme "github-light" | "github-dark" | "preferred-color-scheme" | "github-dark-orange" | "icy-dark" | "dark-blue" | "photon-dark" | "boxy-light" | "gruvbox-dark" "github-light" A Theme that matches your blog.

Returns

React.MutableRefObject<T extends HTMLElement | null> | null

License

MIT

About

Custom hooks to make utterances available in React apps

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published