Introduction | 简体中文 |はじめに
ts-fsrs is a TypeScript toolkit for building spaced repetition systems with FSRS.
ts-fsrs-v6.mp4
This repository contains two main packages:
| Package | Description | Supported FSRS Versions | Package Version | Downloads |
|---|---|---|---|---|
ts-fsrs |
the scheduler for review flows | |||
@open-spaced-repetition/binding |
the optimizer for parameter training and CSV conversion |
ts-fsrs v6 and @open-spaced-repetition/binding require Node.js >=24.0.0.
pnpm add ts-fsrsIf you also need parameter optimization from review logs:
pnpm add @open-spaced-repetition/bindingUse DefaultScheduler() to schedule reviews with ts-fsrs v6. It defaults to FSRS-7; the library version and the FSRS model version are independent.
import { DefaultScheduler, Rating } from 'ts-fsrs'
const now = new Date('2026-01-01T00:00:00.000Z')
const scheduler = await DefaultScheduler()
const card = scheduler.newCard({ now })
// Preview all four possible outcomes before the user answers.
const preview = scheduler.preview({ card, now })
for (const { grade, card: previewCard, revlog } of preview) {
console.log(grade, previewCard, revlog)
}
// Apply the final rating after the user has already answered.
const result = scheduler.review({ card, grade: Rating.Good, now })
console.log(result.card)
console.log(result.revlog)Use @open-spaced-repetition/binding when you want to train FSRS parameters from review logs. For CSV conversion, timezone handling, browser/WASI setup, and training examples, see packages/binding/README.md.
For detailed usage, advanced examples, browser/WASI setup, and API notes:
packages/fsrs/README.mdpackages/binding/README.md- Quick start
- API reference
- Playground
- v5 → v6 and FSRS-7 migration
FSRS is also available in other languages and ecosystems:
For how to setup a local development eniroment, how to set up a Dev Container, and contribution guidelines, see CONTRIBUTING.md.