npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tiny-react-captcha

v1.0.15

Published

A tiny captcha component for React

Readme

Tiny React Captcha

A tiny captcha component for React

  • 14.8kb minified, 5.6kb gzipped
  • client side only
  • using a canvas element to paint chars
  • fully customizable
  • simple bot detection (/src/utils/behaviour.ts, /src/Captcha.tsx)
  • works for SSR
  • no dependencies

Installation

yarn add tiny-react-captcha

or

npm install tiny-react-captcha

Basic usage

This is supposed to work for most cases.

import { useState } from 'react'
import TinyReactCaptcha from 'tiny-react-captcha'
import 'tiny-react-captcha/lib/trc-styles.css'


function Login() {
    const [captchaOk, setCaptchaOk] = useState(false);

    return (
        <main>
            <h1>Sign in</h1>
            {!captchaOk ? (
                <TinyReactCaptcha
                    okCallback={setCaptchaOk}
                />
            ) : (
                <form>
                    <input type="text" />
                    <input type="password" />
                    <input type="submit" />
                </form>
            )}
        </main>
    );
}

Server side rendering

Server side rendering might lead to hydration errors (react-router v7, >= React 19). To avoid this, render the component on client side only. See two examples below.

Example using useEffect

import { useState } from 'react'
import TinyReactCaptcha from 'tiny-react-captcha'
import 'tiny-react-captcha/lib/trc-styles.css'

function Login() {
    const [captchaOk, setCaptchaOk] = useState(false);
    const [showComponent, setShowComponent] = useState(false)

    useEffect(() => {
        setShowComponent(true)
    }, [])

    return (
        <main>
            <h1>Sign in</h1>
            {!captchaOk && showComponent ? (
                <TinyReactCaptcha
                    okCallback={setCaptchaOk}
                />
            ) : null } 
            {showComponent && captchaOk ? (
                <form>
                    <input type="text" />
                    <input type="password" />
                    <input type="submit" />
                </form>
            ) : null}
        </main>
    );
}

Example using <ClientOnly>

import { useState, lazy, Suspense } from 'react'
import { ClientOnly } from "remix-utils/client-only";
import 'tiny-react-captcha/lib/trc-styles.css'

const TinyReactCaptcha = lazy(() => import('tiny-react-captcha'));


function Login() {
    const [captchaOk, setCaptchaOk] = useState(false);
    return (
        <main>
            <h1>Sign in</h1>
            {!captchaOk ? (
                <Suspense fallback={null}>
                     <ClientOnly fallback={null}>
                        {() => (
                            <TinyReactCaptcha
                                okCallback={setCaptchaOk}
                            />
                         )}
                    </ClientOnly>
                </Suspense>
            ) : (
                <form>
                    <input type="text" />
                    <input type="password" />
                    <input type="submit" />
                </form>
            )}
        </main>
    );
}

Usage with Remix.run

If used in remix, you might need to add the package as serverDependenciesToBundle in remix.config.js

  serverDependenciesToBundle: ["tiny-react-captcha"]

Properties

| Required | Property | Type | Default | Description | | -- | ------------------ | ------------------- | ------------------- | ------------------- | |true| okCallback| (e: true) => void | | returns true if captcha solved| |false| failCallback | (e: true) => void | | returns true if amount of attempts is equal or higher than maxAttempts| |false| stringMinLen | number | 1-7 | min length of Captcha string| |false| stringMaxLen | number | 1-7 | max length of Captcha string| |false| captchaStringType, abcLowerCase, abcUpperCase, numbers, abc123Complete, abcComplete, abc123Friendly, custom | abc123Friendly | type of signs shown as captcha. See src/constants/index.ts | |false| captchaCharsCollection | string | undefined | a collection of chars and or numbers used for the Captcha | |false| caseSensitive | boolean | false | does user input need to be case sensitive? | |false| timeBeforeInputInMS | number | 2_000 | if user enters captcha faster, captcha is not considered as solved correctly | |false| maxAttempts | number | 4 | max number of attempts before abort and optionally failCallback fires | |false| perferedTheme | auto, light, dark | auto | Color theme | |false| language |en, de, fr, it, zh, es, pt| en | language of displayed texts | |false| useStyleSheet | boolean | true | If default CSS stylesheet is included. If set to false, no CSS classNames are added | |false| htmlPropsForm | HTMLAttributes<HTMLFormElement> | undefined | inject html props | |false| htmlPropsTitle | HTMLAttributes<HTMLDivElement> | undefined | inject html props | |false| htmlPropsCanvasFrame | HTMLAttributes<HTMLDivElement> | undefined | inject html props | |false| htmlPropsCanvas | HTMLAttributes<HTMLCanvasElement> | undefined | inject html props | |false| htmlPropsRefreshButton | HTMLAttributes<HTMLButtonElement> | undefined | inject html props | |false| htmlPropsInputFrame | HTMLAttributes<HTMLFieldSetElement> | undefined | inject html props | |false| htmlPropsLabel | HTMLAttributes<HTMLLabelElement> | undefined | inject html props | |false| htmlPropsLabelText | HTMLAttributes<HTMLSpanElement> | undefined | inject html props | |false| htmlPropsInput | HTMLAttributes<HTMLInputElement> | undefined | inject html props | |false| htmlPropsOkButton | HTMLAttributes<HTMLButtonElement> | undefined | inject html props | |false| htmlPropsFail | HTMLAttributes<HTMLDivElement> | undefined | inject html props | |false| textTitle | string | undefined | custom text | |false| textTryAgain | string | undefined | custom text | |false| textEnterCaptcha | string | undefined | custom text | |false| textOk | string | undefined | custom text | |false| textFail | string | undefined | custom text |