Skip to main content
The SvelteURL class provides a reactive wrapper around JavaScript’s URL object. When you modify URL properties, Svelte’s reactivity system is automatically notified.

Import

Usage

Basic usage

URL builder

Properties

All standard URL properties are reactive:
  • href - The full URL
  • protocol - The protocol (e.g., ‘https:’)
  • hostname - The hostname
  • port - The port
  • pathname - The path
  • search - The query string
  • hash - The hash fragment
  • searchParams - URLSearchParams object (also reactive)

Notes

  • All URL property modifications trigger reactivity
  • The searchParams property is also reactive
  • Useful for building and manipulating URLs reactively
  • Works with relative and absolute URLs

See also