Install the adapter for your framework with your preferred package manager:
npm i @tanstack/react-hotkeyspnpm add @tanstack/react-hotkeysyarn add @tanstack/react-hotkeysbun add @tanstack/react-hotkeysEvery framework adapter re-exports the core @tanstack/hotkeys package, so you don't need to install both.
Note
Not using a framework? Install @tanstack/hotkeys directly for vanilla JavaScript or TypeScript.
The types need TypeScript 5.4 or later. defineAppHotkeys needs TypeScript 6.0 or later for a declaration with more than a hotkey: an earlier version reports that the declaration "is not assignable to type 'defineAppHotkeys needs TypeScript 6.0 or later'". An earlier version also can't tell a chord from a sequence in alternates written inline in a declaration, so it rejects timeout for that app hotkey.
Requires React 18 or newer. useHotkey is a client hook and HotkeysProvider is a client component, so server components like Next.js app/layout.tsx can render HotkeysProvider directly. To pass appHotkeys from a Server Component, use AppHotkeysProvider instead. See App hotkeys with Server Components.
Start with the React Quick Start. To add the devtools panel, install:
npm i @tanstack/react-devtools
npm i @tanstack/react-hotkeys-devtoolspnpm add @tanstack/react-devtools
pnpm add @tanstack/react-hotkeys-devtoolsyarn add @tanstack/react-devtools
yarn add @tanstack/react-hotkeys-devtoolsbun add @tanstack/react-devtools
bun add @tanstack/react-hotkeys-devtoolsSee Devtools for setup instructions.