All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
2.2.1 - 2025-07-21
- Zod string formats (e.g.
z.uuid()) are now properly recognized as strings by thezod()helper.
2.2.0 - 2025-07-20
- Allow using Zod v4 in
zod().
2.1.0 - 2025-07-06
- Add support for Standard Schema.
2.0.0 - 2024-11-23
- Add
configure()for configuring types parser globally. - Allow to pass a custom parser as a second argument to all built-in types.
- Expose params kind (
"pathname" | "search" | "hash") for custom parsers to use. - Add pathless routes and route composition API.
// Instead of route(':id', { params: { id: number() }, searchParams: { page: number() } })
const fragment = route({ params: { id: number() }, searchParams: { page: number() } });
// Instead of types(FRAGMENT)({searchParams: { query: string() }})
const myRoute = route({
path: "my-path/:id",
compose: [fragment],
searchParams: { query: string() },
});
const { id } = useTypedParams(fragment);
const [{ page }] = useTypedSearchParams(fragment);union()now accepts enums and readonly (as const) objects.union()now properly infers values from an inline array withoutas const.- Pathname params without explicit types now use
string()andstring().defined()for optional and required params respectively instead of custom code. - State can now optionally be typed as a whole, so non-object states can now be typed.
- Optional splats are now explicitly forbidden (they stopped working in React Router v6.9.0).
- Routes without pathname/search/state params now accept non-empty object as these params.
- Breaking:
union()no longer accepts its values as multiple arguments. - Breaking: Types for pathname
paramsare now stricter and don't allow params which are not specified in the path pattern. This also fixes autocomplete for such params. - Breaking: A
$is added to all fields of a route object, so now child routes can start with a lowercase character and use basically any naming scheme (unless they start with a$, which is forbidden). - Breaking: The
pathandrelativePathroute fields were squashed into the$path()function. It returns an absolute path pattern by default or a relative path pattern if therelativeoption is set totrue. - Breaking: The
typesfield is renamed to$spec, and it now also contains an unmodifiedpathoption of the route. - Breaking: Naming scheme was changed from
getPlain/getTypedtoserialize/deserializefor clarity. - Breaking: Path and state generation API is changed.
$buildPath(formerlybuildPath) now accepts all params as a single argument. Signatures of allbuild*functions were updated accordingly.$buildPathnameis added.buildRelativePathis removed, and instead$buildPathand$buildPathnamenow accept arelativeoption.getUntypedParams,getUntypedSearchParams, andgetUntypedStatewere removed. Instead,$buildPath,$buildSearch,$serializeSearchParams, and$buildStatenow acceptuntypedSearchParamsoruntypedStateoptions where applicable. When provided, the corresponding untyped parts are added to the resulting path (the search part) or state. The corresponding option inuseTypedSearchParamsis also renamed.$serializeSearchParams(formerlygetPlainSearchParams) now returns aURLSearchParamsinstance for consistency with the rest of the API.
- Breaking:
routeAPI is changed. It now accepts a single argument with optional types, path, composed routes and children. By default, path isundefined(which means a pathless route). - Breaking: Hash should now be specified as an array of strings or a type. Empty array now means "nothing" instead of "any string". For example:
hashValues('about', 'info')=>['about', 'info']hashValues()=>string()- Default:
[] - You can also use other types, like
number().default(-1)
- Breaking: Array types like
string().array()now filterundefinedvalues upon parsing. The previous behavior broke a common pattern of changing a subset of search parameters:
const FRAGMENT = route({ searchParams: { pages: number().array(), query: string() } });
const [{ pages, query }, setTypedSearchParams] = useTypedSearchParams(FRAGMENT);
setTypedSearchParams((prevParams) => ({
// Previously, prevParams.pages would be (number|undefined)[],
// which is not assignable to number[].
...prevParams,
query: "hi",
}));- Breaking: Similarly,
undefinedkeys are now omitted from all parsed params to match how there are no such keys in rawparamsfrom React Router. The reason this behavior was originally introduced is not relevant anymore. - Breaking:
$no longer prevents pathname types inheritance. - Breaking: Some types are changed for convenience and readability.
- Breaking: The minimal required version of TS is now
v5.0withstrictmode enabled. - Breaking: The minimal required version of React Router is now
v7.0. - Breaking: CommonJS is now used by default, similarly to React Router.
- Breaking: Removed
/domand/nativeentry points. Use the main entry point instead. - Breaking: Removed all deprecated features.
- Breaking: Removed
hashValues(). Pass an array of strings or a type instead. - Breaking: Removed
types(). Use composition API instead.
1.2.2 - 2024-04-21
- For routes without pathname/search/state params, non-empty objects are no longer accepted as these params.
1.2.1 - 2023-06-20
- Fix path generation when the first segment is optional. Previously,
route(":optional?/:required").buildPath({ required: "req" })would be"//req".
1.2.0 - 2023-04-22
- Add CommonJS support for environments that support the
exportsfield inpackage.json.
1.1.0 - 2023-04-07
- Introduce type objects that allow to fine-tune parsing and serialization logic for every route part.
- Add helpers for creating these type objects. They can generally be used instead of the old ones (see Migrating to Universal Types). The helpers are:
type()for creating any type;parser()for accessing the built-in parser, most likely for building custom wrappers aroundtype();string(),number(),boolean(), anddate()for creating types based on the corresponding primitives;union()for creating unions ofstring,number, andbooleanvalues;zod()for creating types based on Zod Types;yup()for creating types based on Yup Schemas.
- Route params input and output types are now much more readable in IDE hints.
- Specifying a path pattern with leading or trailing slashes or a child route starting with a lowercase letter will now lead to a human-readable error.
- For types of parsed path params, search params, and state fields, keys that correspond to type objects that return
undefinedupon a parsing error are no longer optional.
- Deprecate old helpers for creating type objects:
createType(),stringType(),numberType(),booleanType(),dateType(),oneOfType(),arrayOfType(),throwable, and all types that are exclusive to them. - Deprecate
assertIsString(),assertIsNumber(),assertIsBoolean(),assertIsArray(), andassertIsValidDate()because they are embedded in new helpers, which allow to run additional checks after these assertions.
1.0.0 - 2023-01-23
- Add support for optional path segments.
- Add
types()helper for route types composition. - Add
getUntypedParams()method to route object.
- Intermediate splat (star) segments in absolute path patterns are now properly detected. Previously, their detection didn't work properly if dynamic segments were present. It means that such star params will now correctly appear in parsed (typed) path params.
- Multiple intermediate stars are now properly removed from relative path pattern. This also fixes building URL paths from such patterns.
- Upon building URL paths from patterns with only intermediate stars, the
*parameter is not present anymore, because it doesn't actually do anything (intermediate stars are simply removed).
- Breaking: Fallbacks are now run through type functions to ensure fallbacks validity, and therefore
TRetrievedwas replaced withTOriginalin their type. This is technically a breaking change, but it only affects custom types whereTRetrievedis not assignable toTOriginal, which should be extremely rare. - Breaking: Minimal required React Router version is changed to
6.7.0due to optional path segments support. - Breaking: Rename
ExtractRouteParamstoPathParamfor parity with React Router. - Breaking: In route object,
$no longer contains undecorated child routes. Instead, it now contains routes that lack parent path pattern and path type objects, but inherit everything else. buildPath/buildRelativePathnow accept additional arguments and behave exactly likebuildUrl/buildRelativeUrl.setTypedSearchParamsis switched to React Router implementation of functional updates.
buildUrl/buildRelativeUrlnow behave exactly likebuildPath/buildRelativePathand are therefore deprecated.
- Remove all internal fields prefixed with
__from route objects.
0.5.1 - 2022-12-14
- Add CONTRIBUTING.md
- Sync node version requirements with React Router.
0.5.0 - 2022-09-14
- Expose route
types(previously existed as internal__options__).
- Breaking: Rename
CreateRouteOptionsandRouteOptionsintoRouteOptionsandRouteTypesrespectively.
0.4.3 - 2022-09-11
- Add
throwablefallback.
0.4.2 - 2022-09-10
- Add CHANGELOG.md.
- Add
preserveUntypedoption tosetTypedSearchParamsfromuseTypedSearchParamshook. - Add
getUntypedSearchParamsandgetUntypedStatemethods to route object.
- Return value of
buildStatemethod is now properly typed asRecord<string, unknown>instead ofunknown. - Hook dependencies are now properly listed, which is checked by ESLint. This fixes
useTypedSearchParamsfor dynamic routes. - Prevent access to internal
useUpdatingRefhelper.