Zero dependencies · TypeScript first

URLs, assembled
safely.

Join dynamic URL segments without juggling slashes, optional values, or query strings. Small API. Predictable output.

Try the playground
ESM + CJSTypedTree-shakableProtocol-safe

01 / Playground

Build a URL in real time

The result is generated by the same function published in the package.

Segments

Strings, numbers, booleans, null, and arrays are supported.

Options
Live output
TypeScript

02 / Why it works

Less URL plumbing

One focused utility for the details that make dynamic URLs brittle.

01

Optional by default

Pass null, undefined, or empty strings. They disappear without extra conditionals.

urlJoin('users', userId)
02

Protocol-aware

Normalize repeated slashes while preserving the ones that belong in https://.

https://api.example.com/v1
03

Query-ready

Append typed query parameters, encode values, and merge them with an existing query string.

?page=1&active=true

03 / API

One function.
A few useful options.

Use named or default imports. Every segment can be a string, number, null, or undefined.

Read the full documentation
function urlJoin(...segments, options?) → string
trailingSlash
booleanAdd or remove the final slash.
normalize
booleanNormalize duplicate slashes. Defaults to true.
query
QueryParamsAppend encoded scalar or array values.

Ready when your route is

Stop counting slashes.

Add the package and get back to the code that matters.

View on GitHub