Official documentation of the itty ecosystem.

GitHub edit this page

NPM GitHub

What is it?

This library helps reduce the boilerplate around Durable Objects, allowing you to focus on the business logic of your stateful objects, rather than things like internal routing, building requests, etc.

Now your Durable Object class can look this simple:

import { createDurable } from 'itty-durable'

export class Counter extends createDurable({ autoReturn: true, autoPersist: true }) {
  constructor(state, env) {
    super(state, env)
    this.counter = 0

  increment() {

  setValue(newValue: number) {
    this.counter = newValue

While being able to access them from a Worker much like a native class:

import { Router, error, withParams } from 'itty-router'
import { withDurables } from 'itty-durable'

// export the durable class, per spec
export { Counter } from './Counter'

const router = Router()

  // add upstream middleware
  .all('*', withDurables(), withParams)

  // get the contents of a DO
  .get('/:id', ({ id, Counter }) => 

  // call a method on the DC
  .get('/:id/increment', ({ id, Counter }) => 

  // or pass data to a method
  .get('/set/:value', withParams, ({ id, value, Counter }) =>