Documentation Index
Fetch the complete documentation index at: https://mintlify.com/get-convex/rate-limiter/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Thecheck() method checks a rate limit’s current status without consuming any tokens. This is useful for previewing whether a request would be allowed, or for checking rate limits in queries where you cannot consume tokens.
Method Signature
Key Difference from limit()
Unlikelimit(), the check() method:
- Does not consume tokens - It only reads the current state
- Can be used in queries - Since it doesn’t mutate state, it works with
runQuery - Returns the same shape - The return type is identical to
limit()
check() perfect for UI indicators, permission checks, or deciding whether to attempt an operation.
Parameters
The context object from a query or mutation, including
runQuery. Unlike limit(), this works with query contexts.The name of the rate limit to check. If this name was defined in the
RateLimiter constructor, it will be type-checked and auto-completed.Optional configuration for this rate limit check.
A unique identifier for this rate limit instance. Use this to check per-user, per-IP, or other scoped rate limits.
The number of tokens to check for availability. The check will return whether this many tokens are available without consuming them.
If
true, checks whether tokens can be reserved for future use. Returns retryAfter indicating when the reserved work should execute.The rate limit configuration. Required only if the rate limit name was not defined in the
RateLimiter constructor.The
throws option is not available for check() since it’s typically used for non-blocking status checks.Return Type
Returns a promise that resolves to one of two shapes:When rate limit is not exceeded:When rate limit is exceeded:
Indicates the request would be allowed.
Only present when
reserve: true. The duration in milliseconds to wait before executing the reserved work.Indicates the rate limit would be exceeded.
The duration in milliseconds when retrying could succeed.
Use Cases
Preview Before Action
Check if an action would be rate-limited before attempting it:Query for UI Status
Use in a query to show rate limit status in your UI:Batch Operations
Check if multiple operations would succeed before starting:Cost Estimation
Check if a large operation would be allowed:Notes
Since
check() doesn’t consume tokens, calling it multiple times won’t affect the rate limit state. This makes it safe to use in queries and for UI status indicators.When using
check() followed by limit() in the same mutation, there’s a small time gap between the check and the actual consumption. The rate limit state could change between these calls. Use check() for guidance, not as a guarantee.Related Methods
limit()- Check and consume rate limit tokensgetValue()- Get detailed rate limit statereset()- Reset a rate limit