Using custom query parameters in editing render handlers
Content SDK's editing render handlers (/api/editing/render) only recognize a fixed set of required query parameters needed to initiate an editing session (sc_itemid, sc_lang, mode, and route). Any additional query parameters present in the request URL are silently ignored and never forwarded to the rendering pipeline.
To explicitly include additional query parameters, you can use the allowedQueryParams configuration option. It gives you explicit control over which custom query parameters are extracted from the incoming request URL and propagated through the editing session, either into Next.js preview data (Pages Router) or into the forwarded render request (App Router).
Examples
The following sections depict the usage of the allowedQueryParams configuration option in Pages Router and App Router apps.
Pages Router
Configure allowedQueryParams in your editing render API route as shown:
App Router
Configure allowedQueryParams when calling createEditingRenderRouteHandlers as shown:
Using a resolver function
If the parameters you want to allow follow a naming pattern or are only known at runtime, use a resolver function as shown:
Validation and error handling
When allowedQueryParams is configured, the SDK validates both the standard editing parameters and your custom required parameters before rendering proceeds.
If any parameter marked as required: true is missing from the request, the handler immediately returns an HTTP 400 response with an HTML body listing all missing parameters:
Parameters marked as required: false or configured as plain strings are optional. When absent, they're omitted from the forwarded data without triggering an error.
Reference
The following types are exported from @sitecore-content-sdk/nextjs:
-
AllowedQueryParam— interface defining an individual allowed parameter -
AllowedQueryParams— union type for the full allowedQueryParams config value -
AllowedQueryParamsResolver— function type for the dynamic resolver form
The allowedQueryParams option is available on both the Pages Router and App Router editing render handlers.
AllowedQueryParam interface
The interface for the allowedQueryParams option that defines which extra query params to allow. Can be a static array or a resolver function.
AllowedQueryParams type
String entries in the array are treated as optional parameters by default.
AllowedQueryParamsResolver type
A resolver function receives the full list of query parameter keys from the incoming request URL and returns the list of parameters to allow. This is useful when the set of allowed parameters is dynamic or prefix-based.