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

secret-sequence-react

v1.0.0

Published

React hook & component wrapper for secret-sequence-core — detect directional sequences, key combos, and touch gestures

Downloads

5

Readme

Secret Sequence React

en es

GitHub stars GitHub forks GitHub issues GitHub Sponsors

React TypeScript

React hook & component for detecting directional sequences, key combos, and touch gestures — powered by secret-sequence-core.

This package provides React bindings for the Secret Sequence monorepo.
It wraps the core engine in a hook and a declarative component with full lifecycle management.


Installation

npm install secret-sequence-react secret-sequence-core

secret-sequence-core is a peer dependency.


Quick Start

Hook — useSecretSequence

import { useSecretSequence } from "secret-sequence-react"

function App() {
  const { progress } = useSecretSequence({
    sequences: [
      {
        id: "konami",
        sequence: ["up", "up", "down", "down", "left", "right", "left", "right"],
        onSuccess: () => alert("🎉 Konami Code activated!"),
      },
    ],
    enableTouch: true,
    touchOptions: { minDistance: 50, maxTime: 400 },
  })

  return <pre>{JSON.stringify(progress, null, 2)}</pre>
}

Component — <SecretSequence />

Invisible Mode (effect only)

import { SecretSequence } from "secret-sequence-react"

function App() {
  return (
    <SecretSequence
      sequences={[
        {
          id: "konami",
          sequence: ["up", "up", "down", "down", "left", "right", "left", "right"],
          onSuccess: () => console.log("🎉"),
        },
      ]}
      enableTouch={true}
      touchOptions={{ minDistance: 40 }}
    />
  )
}

With render prop

<SecretSequence
  sequences={[{ id: "code", sequence: ["up", "down"], onSuccess: fn }]}
>
  {({ progress, reset }) => (
    <div>
      <p>Progress: {JSON.stringify(progress)}</p>
      <button onClick={reset}>Reset</button>
    </div>
  )}
</SecretSequence>

Stratagem-Style Input

const { progress } = useSecretSequence({
  sequences: [
    {
      id: "orbitalStrike",
      sequence: ["right", "right", "up"],
      onSuccess: () => deployStrike(),
    },
  ],
  timeout: 2000,
})

Key Combo Shortcut

const { progress } = useSecretSequence({
  sequences: [
    {
      id: "shortcut",
      sequence: [{ key: "k", ctrl: true }],
      onSuccess: () => console.log("Shortcut triggered"),
    },
  ],
})

Touch Gesture Support

Swipe gestures on touch devices are automatically mapped to directional steps.

const { progress } = useSecretSequence({
  sequences: [
    {
      id: "swipe-pattern",
      sequence: ["up", "down", "left", "right"],
      onSuccess: () => alert("Swipe pattern detected!"),
    },
  ],
  enableTouch: true,
  touchOptions: {
    minDistance: 30,
    maxTime: 300,
    threshold: 1.5,
  },
})

API

useSecretSequence(options)

React hook that manages the engine lifecycle automatically.

Returns: { progress, reset }

| Return | Type | Description | | ---------- | -------------------------- | ----------------------------- | | progress | Record<string, number> | Current progress per sequence | | reset | () => void | Reset all sequence progress |


<SecretSequence /> Component

Declarative JSX wrapper over the useSecretSequence hook.

| Prop | Type | Description | | ------------------ | ----------------------------------------------------------------------- | ---------------------------------------- | | onProgressChange | (progress: Record<string, number>) => void | Callback fired on progress changes | | children | (state: { progress: Record<string, number>; reset: () => void }) => … | Optional render prop for progress/reset | | ...hookOptions | UseSecretSequenceOptions | All hook options (see below) |


Options (shared by hook & component)

| Option | Type | Default | Description | | -------------- | ------------------------ | ------- | ------------------------------------------------------ | | sequences | SecretSequenceConfig[] | — | Array of sequences to detect simultaneously | | timeout | number | 2000 | Milliseconds of inactivity before resetting progress | | enabled | boolean | true | Globally enable or disable detection | | enableTouch | boolean | true | Enable swipe gesture detection | | ignoreInputs | boolean | true | Ignore key events when focus is on input-like elements | | touchOptions | TouchConfig | — | Advanced touch configuration |


Configuration Types

SecretSequenceConfig

| Property | Type | Description | | ----------- | --------------------- | ------------------------------------------- | | id | string (optional) | Unique identifier (defaults to array index) | | sequence | SequenceStep[] | Ordered steps to detect | | onSuccess | () => void | Fired when the sequence completes |


Core Types

type Direction = "up" | "down" | "left" | "right"

type KeyCombo = {
  key: string
  ctrl?: boolean
  shift?: boolean
  alt?: boolean
  meta?: boolean
}

type SequenceStep = Direction | KeyCombo

TouchConfig

| Property | Type | Default | Description | | ------------- | -------- | ------- | ---------------------------------------------- | | minDistance | number | 30 | Minimum swipe distance (px) | | maxTime | number | 300 | Maximum swipe duration (ms) | | threshold | number | 1.5 | Axis dominance ratio to reject diagonal swipes |


SSR Compatibility

This package is safe to use in SSR environments such as Next.js or Remix.

The underlying engine guards against accessing window during server rendering and only attaches event listeners in the browser.


License

MIT © Diego Alonso