Skip to main content

Overview

The createSerializer function creates a type-safe serializer for generating URLs with search parameters. It’s useful for creating links, redirects, and programmatic navigation with properly formatted query strings.

Function Signature

Parameters

ParserMap
required
An object mapping search param keys to their parser configurations.
CreateSerializerOptions<Parsers>
Optional configuration object.

Return Value

Returns a SerializeFunction with two overloads:

Base Types

Nullable Type Helper

Values can be set to null to remove them from the URL.

Type Definitions

ParserMap

CreateSerializerOptions

inferParserType

TypeScript automatically infers types based on your parsers:

Examples

Generate Query String

Append to Base URL

Remove Parameters with null

Default Value Behavior

Disable clearOnDefault

URL Keys Mapping

Post-Processing

Server-Side Redirects (Next.js)

API Routes

Complex Serialization

Type Safety

The serializer is fully type-safe:

Serializer Guide

Learn how to use serializers for URLs

createLoader

Parse search params with createLoader

createSearchParamsCache

Cache search params in server components

Parsers

Learn about available parser types