API reference › @evolu/common › local‑first/Owner › RelayUrl
const RelayUrl: brand(
"RelayUrl",
WebSocketUrl,
(value: string) =>
// Only a query adds "?" to a serialized URL without a fragment.
value.includes("?")
? err<RelayUrlError>({ type: "RelayUrl", value })
: ok(),
(error) =>
`The value ${JSON.stringify(error.value)} is not a relay URL, which has no query.`,
);
Defined in: packages/common/src/local-first/Owner.ts:583
WebSocketUrl of a relay, which has no query, such as
wss://free.evoluhq.com/.
createOwnerWebSocketTransport adds the OwnerId as the query. A relay that admits a connection by a credential beyond the OwnerId, such as a token that a reverse proxy checks, takes it in the path. Like WebSocketUrl, RelayUrl does not normalize; use RelayUrlFromString to convert other spellings, such as user input.
Example
import { assertErr, assertOk, RelayUrl } from "@evolu/common";
assertOk(
RelayUrl.fromUnknown("wss://free.evoluhq.com/"),
"wss://free.evoluhq.com/",
);
assertErr(RelayUrl.fromUnknown("wss://free.evoluhq.com/?token=1"), {
type: "RelayUrl",
value: "wss://free.evoluhq.com/?token=1",
});