Optional by default
Pass null, undefined, or empty strings. They disappear without extra conditionals.
urlJoin('users', userId)Zero dependencies · TypeScript first
Join dynamic URL segments without juggling slashes, optional values, or query strings. Small API. Predictable output.
01 / Playground
The result is generated by the same function published in the package.
02 / Why it works
One focused utility for the details that make dynamic URLs brittle.
Pass null, undefined, or empty strings. They disappear without extra conditionals.
urlJoin('users', userId)Normalize repeated slashes while preserving the ones that belong in https://.
https://api.example.com/v1Append typed query parameters, encode values, and merge them with an existing query string.
?page=1&active=true03 / API
Use named or default imports. Every segment can be a string, number, null, or undefined.
booleanAdd or remove the final slash.booleanNormalize duplicate slashes. Defaults to true.QueryParamsAppend encoded scalar or array values.Ready when your route is
Add the package and get back to the code that matters.