Skip to content
Back to skills

Orpc Ratelimit

ASecurity

Rate limiting for oRPC with multiple storage backend support.

  • 8 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 12, 2026
businessgitbackend

Works with

  • cli

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned September 12, 2026

npx -y skills add ali-master/skills --skill orpc-ratelimit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Orpc Ratelimit?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Orpc Ratelimit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ali-master-orpc-ratelimit/badge)](https://www.skillsdirectory.com/skills/ali-master-orpc-ratelimit)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: oRPC Rate Limit
description: Rate limiting for oRPC with multiple storage backend support.
license: MIT
metadata:
  author: Ali Torki
  homepage: https://github.com/ali-master
  version: "1.0.0"
---

# Rate Limit

Flexible rate limiting with multiple storage backends — memory, Redis, Upstash.

## Installation

```sh
npm install @orpc/experimental-ratelimit@latest
```

## Adapters

### Memory

```ts
import { MemoryRatelimiter } from '@orpc/experimental-ratelimit/memory'

const limiter = new MemoryRatelimiter({
  maxRequests: 10,
  window: 60000, // 60 seconds
})
```

### Redis

Uses atomic Lua scripts for distributed rate limiting.

```ts
import { RedisRatelimiter } from '@orpc/experimental-ratelimit/redis'
import { Redis } from 'ioredis'

const redis = new Redis('redis://localhost:6379')

const limiter = new RedisRatelimiter({
  // Provide a Redis Lua script runner
  exec: async (script, numKeys, ...rest) => redis.eval(script, numKeys, ...rest),
  maxRequests: 100,
  window: 60000,
  prefix: 'orpc:ratelimit:',
})
```

> Any Redis client that supports Lua scripts works.

### Upstash Ratelimit

```ts
import { Ratelimit } from '@upstash/ratelimit'
import { Redis } from '@upstash/redis'
import { UpstashRatelimiter } from '@orpc/experimental-ratelimit/upstash-ratelimit'

const redis = Redis.fromEnv()
const ratelimit = new Ratelimit({
  redis,
  limiter: Ratelimit.slidingWindow(10, '60 s'),
  prefix: 'my-app:',
})

const limiter = new UpstashRatelimiter(ratelimit)

// Edge runtime — pass waitUntil:
const edgeLimiter = new UpstashRatelimiter(ratelimit, {
  waitUntil: ctx.waitUntil.bind(ctx),
})
```

### Cloudflare Ratelimit

```ts
import { CloudflareRatelimiter } from '@orpc/experimental-ratelimit/cloudflare-ratelimit'

export default {
  async fetch(request, env) {
    const limiter = new CloudflareRatelimiter(env.MY_RATE_LIMITER)
    return new Response(`Hello World!`)
  }
}
```

## Blocking Mode

```ts
const limiter = new MemoryRatelimiter({
  maxRequests: 10,
  window: 60000,
  blockingUntilReady: {
    enabled: true,
    timeout: 5000,
  },
})
```

## Manual Usage

```ts
import { ORPCError } from '@orpc/server'

const result = await limiter.limit('user:123')

if (!result.success) {
  throw new ORPCError('TOO_MANY_REQUESTS', {
    data: {
      limit: result.limit,
      remaining: result.remaining,
      reset: result.reset,
    },
  })
}
```

## `createRatelimitMiddleware`

```ts
import { createRatelimitMiddleware, Ratelimiter } from '@orpc/experimental-ratelimit'

const loginProcedure = os
  .$context<{ ratelimiter: Ratelimiter }>()
  .input(z.object({ email: z.email() }))
  .use(
    createRatelimitMiddleware({
      limiter: ({ context }) => context.ratelimiter,
      key: ({ context }, input) => `login:${input.email}`,
    }),
  )
  .handler(({ input }) => ({ success: true }))
```

> Automatically deduplicates rate limit checks. Disable with `dedupe: false`.

## Handler Plugin

```ts
import { RatelimitHandlerPlugin } from '@orpc/experimental-ratelimit'

const handler = new RPCHandler(router, {
  plugins: [new RatelimitHandlerPlugin()],
})
```

Adds `RateLimit-*` and `Retry-After` headers. Combine with [Retry After Plugin](/docs/plugins/retry-after) for automatic retries.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.