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 URLprotocol- The protocol (e.g., ‘https:’)hostname- The hostnameport- The portpathname- The pathsearch- The query stringhash- The hash fragmentsearchParams- URLSearchParams object (also reactive)
Notes
- All URL property modifications trigger reactivity
- The
searchParamsproperty is also reactive - Useful for building and manipulating URLs reactively
- Works with relative and absolute URLs