{"record":{"id":"3a5d6291fb25c165","repo":"vercel/next.js","slug":"method-unavailable-on-readonlyurlsearchparams-r","errorCode":null,"errorMessage":"Method unavailable on `ReadonlyURLSearchParams`. Read more: https://nextjs.org/docs/app/api-reference/functions/use-search-params#updating-searchparams","messagePattern":"Method unavailable on `ReadonlyURLSearchParams`\\. Read more: https://nextjs\\.org/docs/app/api-reference/functions/use-search-params#updating-searchparams","errorType":"exception","errorClass":"ReadonlyURLSearchParamsError","httpStatus":null,"severity":"error","filePath":"packages/next/src/client/components/readonly-url-search-params.ts","lineNumber":23,"sourceCode":" */\n\n/** @internal */\nclass ReadonlyURLSearchParamsError extends Error {\n  constructor() {\n    super(\n      'Method unavailable on `ReadonlyURLSearchParams`. Read more: https://nextjs.org/docs/app/api-reference/functions/use-search-params#updating-searchparams'\n    )\n  }\n}\n\n/**\n * A read-only version of URLSearchParams that throws errors when mutation methods are called.\n * This ensures that the URLSearchParams returned by useSearchParams() cannot be mutated.\n */\nexport class ReadonlyURLSearchParams extends URLSearchParams {\n  /** @deprecated Method unavailable on `ReadonlyURLSearchParams`. Read more: https://nextjs.org/docs/app/api-reference/functions/use-search-params#updating-searchparams */\n  append() {\n    throw new ReadonlyURLSearchParamsError()\n  }\n  /** @deprecated Method unavailable on `ReadonlyURLSearchParams`. Read more: https://nextjs.org/docs/app/api-reference/functions/use-search-params#updating-searchparams */\n  delete() {\n    throw new ReadonlyURLSearchParamsError()\n  }\n  /** @deprecated Method unavailable on `ReadonlyURLSearchParams`. Read more: https://nextjs.org/docs/app/api-reference/functions/use-search-params#updating-searchparams */\n  set() {\n    throw new ReadonlyURLSearchParamsError()\n  }\n  /** @deprecated Method unavailable on `ReadonlyURLSearchParams`. Read more: https://nextjs.org/docs/app/api-reference/functions/use-search-params#updating-searchparams */\n  sort() {\n    throw new ReadonlyURLSearchParamsError()\n  }\n}\n","sourceCodeStart":5,"sourceCodeEnd":38,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/client/components/readonly-url-search-params.ts#L5-L38","documentation":"Mutation guard on ReadonlyURLSearchParams: a mutating URLSearchParams method such as append was called on the object returned by useSearchParams. The wrapper class throws ReadonlyURLSearchParamsError from every mutator because search params are owned by the router and must be updated via navigation, not in place.","triggerScenarios":"A mutating method is called on the read-only URLSearchParams from useSearchParams.","commonSituations":"Calling set/append/delete on the search params object returned by useSearchParams instead of using the router.","solutions":["Do not mutate ReadonlyURLSearchParams; build a new URLSearchParams from useSearchParams() and navigate with router.push/replace instead."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0eb377541648e63402a47b38fee00a8d0ce8f8f1","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}