async-params

Guidelines for handling `params` and `searchParams` in Next.js 15 page components, where these values must be treated as Promises and awaited.

In plain words
What is it for?
Use them to check page prop types, make page functions asynchronous, and ensure route parameters and URL search values are awaited before use.
Why use it?
They catch older usage patterns that can break or behave incorrectly in Next.js 15 pages.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/squirrelogic/cursor-rules/async-params
Clone the repo
git clone --depth 1 https://github.com/squirrelogic/cursor-rules
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 923 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00923
Opus 5 $0.00000 $0.00462
Sonnet 5 $0.00000 $0.00185
Haiku 4.5 $0.00000 $0.00092

Measured 3d ago against content hash 9735128e0af9, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

async-params scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

nextjs/async-params.mdc · 126 lines

What it actually says

Async Params and SearchParams in Next.js 15

actions:

  • type: reject conditions:

    • pattern: "params\s*:\s*\{\s*[a-zA-Z_][a-zA-Z0-9_]\s:\sstring\s\}" message: "Page params must be typed as a Promise and awaited"

    • pattern: "searchParams\s*:\s*\{[^}]*\}" message: "Page searchParams must be typed as a Promise and awaited"

    • pattern: "const\s+\{\s*[a-zA-Z_][a-zA-Z0-9_]\s\}\s*=\s*params" message: "Page params must be awaited before destructuring"

    • pattern: "const\s+\{\s*[a-zA-Z_][a-zA-Z0-9_]\s\}\s*=\s*searchParams" message: "Page searchParams must be awaited before destructuring"

  • type: suggest message: |

    Async Params and SearchParams

    In Next.js 15, page components that use params or searchParams must:

    1. Be async functions
    2. Type params/searchParams as Promises
    3. Await the params/searchParams before use

    Params Example

    // ✅ DO: Properly type and await params
    interface PageProps {
      params: Promise<{ slug: string }>
    }
    
    export default async function Page({ params }: PageProps) {
      const { slug } = await params
      return <div>Post: {slug}</div>
    }
    
    // ❌ DON'T: Use params without Promise type and await
    interface PageProps {
      params: { slug: string }  // Wrong! Should be Promise
    }
    
    export default function Page({ params }: PageProps) {
      const { slug } = params   // Wrong! Should await params
      return <div>Post: {slug}</div>
    }
    

    SearchParams Example

    // ✅ DO: Properly type and await searchParams
    interface PageProps {
      searchParams: Promise<{ q?: string }>
    }
    
    export default async function Page({ searchParams }: PageProps) {
      const { q } = await searchParams
      return <div>Search: {q}</div>
    }
    
    // ❌ DON'T: Use searchParams without Promise type and await
    interface PageProps {
      searchParams: { q?: string }  // Wrong! Should be Promise
    }
    
    export default function Page({ searchParams }: PageProps) {
      const { q } = searchParams   // Wrong! Should await searchParams
      return <div>Search: {q}</div>
    }
    

    Best Practices

    1. Always make page components async when using params/searchParams
    2. Always type params/searchParams as Promises
    3. Always await params/searchParams before destructuring
    4. Consider handling loading states while params are being resolved
    5. Use TypeScript for better type safety

    Common Patterns

    // Multiple params
    interface PageProps {
      params: Promise<{
        slug: string
        id: string
      }>
    }
    
    // Both params and searchParams
    interface PageProps {
      params: Promise<{ slug: string }>
      searchParams: Promise<{ page?: string }>
    }
    
    // With error handling
    export default async function Page({ params }: PageProps) {
      try {
        const { slug } = await params
        // Use slug
      } catch (error) {
        notFound()
      }
    }
    

metadata: priority: high version: 1.0 framework: next.js frameworkVersion: "15.0.0"

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 126 lines · 0 tokens per session scan A 9735128e0af9

Subscribe to this mod's changes

async-params is a cursor rule published in the GitHub repository squirrelogic/cursor-rules (20 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 923 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.