GitHub 37
Skip to content
ViteHub is still experimental. Expect bugs and breaking changes.

Rate Limit

Cap how many requests each client or user can make, and reject the extra ones with a 429 error.

nuxt.config.ts
export default defineNuxtConfig({
  modules: ['vite-hub/nuxt'],
  vitehub: {
    host: 'node',
    // On Node, counts stay in memory. Turn on shared KV to share them.
    rateLimit: true,
  },
})
nuxt.config.ts
Deploy on

Node / Docker: memory, or KV

One line guards a route

requireRateLimit() lets the request continue or stops it with a 429 error.

Count per user or per team

Each client IP address has its own count. Pass key to count per user or team.

Choose your own response

limiter.consume() returns the result without throwing.

Memory on Node, native on Cloudflare

Node counts in memory. Cloudflare uses Cloudflare Rate Limiting.

See each limit before you deploy

The build writes a file listing each limit and what the host guarantees.

Know the limits

In-memory counts reset on restart and are not shared across servers.