{"id":36946885,"url":"https://github.com/wjsoftware/svelte-router","last_synced_at":"2026-03-07T04:01:28.234Z","repository":{"id":277387496,"uuid":"920980625","full_name":"WJSoftware/svelte-router","owner":"WJSoftware","description":"Next-level routing for Svelte and Sveltekit","archived":false,"fork":false,"pushed_at":"2025-12-26T03:37:49.000Z","size":1206,"stargazers_count":55,"open_issues_count":10,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-13T12:20:28.667Z","etag":null,"topics":["mfe","microfrontend","router","single-spa","svelte"],"latest_commit_sha":null,"homepage":"https://svelte-router.dev/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WJSoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-01-23T05:41:27.000Z","updated_at":"2026-01-12T03:55:45.000Z","dependencies_parsed_at":"2025-02-13T17:48:57.263Z","dependency_job_id":"0120ba44-ce42-4ac7-80c6-2f37b9f86c73","html_url":"https://github.com/WJSoftware/svelte-router","commit_stats":null,"previous_names":["wjsoftware/wjfe-n-savant","wjsoftware/svelte-router-core","wjsoftware/svelte-router"],"tags_count":33,"template":false,"template_full_name":null,"purl":"pkg:github/WJSoftware/svelte-router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WJSoftware%2Fsvelte-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WJSoftware%2Fsvelte-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WJSoftware%2Fsvelte-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WJSoftware%2Fsvelte-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WJSoftware","download_url":"https://codeload.github.com/WJSoftware/svelte-router/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WJSoftware%2Fsvelte-router/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30207390,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T03:24:23.086Z","status":"ssl_error","status_checked_at":"2026-03-07T03:23:11.444Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mfe","microfrontend","router","single-spa","svelte"],"created_at":"2026-01-13T11:32:18.561Z","updated_at":"2026-03-07T04:01:28.194Z","avatar_url":"https://github.com/WJSoftware.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# \u003cimg src=\"src/lib/logo/logo-48.svg\" alt=\"Svelte Router Logo\" width=\"48\" height=\"48\" align=\"left\"\u003e\u0026nbsp;Svelte Router\n\n\u003e Next-level routing for Svelte and Sveltekit.\n\n[REPL Demo](https://svelte.dev/playground/d273d356947e48c0822a65402fd06fac)\n\n[Full Documentation](https://svelte-router.dev)\n\n## Features\n\n- **Always-on path and hash routing**: Simultaneous, independent and always-on routing modes.\n- **Multi hash routing**: Doing micro-frontends? Routing tabs or dialogs using the URL? Have as many paths as needed.\n- **Sveltekit support**: Add hash routing on top of Sveltekit's path routing via\n  [@svelte-router/kit](https://github.com/WJSoftware/svelte-router-kit)\n- **Electron support**: Works with Electron (all routing modes)\n- **Reactivity-based**: All data is reactive, reducing the need for events and imperative programming.\n- **URL Redirection**: Use `Redirector` instances to route users from deprecated URL's to new URL's, even across\n  routing universes.\n- **Dynamic Routes**: Define routes in JavaScript from any dynamic source, even fetched data.\n- **Fully Typed**: Built-in TypeScript, even for route parameters.\n\n**Components**:\n\n- `\u003cRouter\u003e`\n- `\u003cRoute\u003e`\n- `\u003cFallback\u003e`\n- `\u003cLink\u003e`\n- `\u003cLinkContext\u003e`\n- `\u003cRouterTrace\u003e`\n\n**Reactive Data**:\n\n- `location.url`\n- `location.path`\n- `location.hashPaths`\n- `location.getState()`\n- `RouterEngine.routes`\n- `RouterEngine.routeStatus`\n- `RouterEngine.basePath`\n\nAll data is a Svelte signal. Add routes dynamically or reactively, change route conditions on the fly, add more pieces\nof user interface on-demand, etc. All works reactively.\n\n### Two Library Modes\n\nMost people only need the normal or \"lite\" version. Use the full version to battle/counter foreign routers\n(micro-frontend scenarios, most likely).\n\n#### In Full Mode...\n\n- **History API interception**: Gain control over the history object to avoid external code/routers from\n  de-synchronizing state.\n- **Cancellable `beforeNavigate` event**: Get notified of navigation events, and cancel when appropriate.\n- **`navigationCancelled` event**: Get notified whenever navigation is cancelled.\n\n## Quickstart\n\n1. Install the package.\n2. Initialize the library.\n3. Define the routes inside routers.\n4. Modify/Add your navigation links.\n\n### Install the package\n\n```bash\nnpm i @svelte-router/core\n```\n\n### Initialize the Library\n\n```typescript\n// In your main.ts, or somewhere BEFORE any routers are created:\nimport { init } from '@svelte-router/core';\n\n/*\nDefault:\n\n- Lite mode\n- Implicit path routing\n- No router hierarchy tracing\n- Single hash mode\n- Log to console.\n*/\ninit(); // Or use initFull() for full-mode.\n\n// Common case:  \"I just need good, old-fashioned hash routing.\"\ninit({ defaultHash: true });\n```\n\n#### Electron Variant\n\nIn Electron, perform immediate navigation to clean the environment's path:\n\n```typescript\nimport { init, location } from '@svelte-router/core';\n\ninit();\nlocation.goTo('/');\n```\n\n\u003e **⚠️ Important:** Hash routing doesn't require this extra navigation step.\n\nFor applications that also run in the browser, condition the navigation to Electron only. See the\n[Electron page](https://svelte-router.dev/docs/electron-support) online for more\ndetails.\n\n### Define the Routes\n\n```svelte\n\u003cscript lang=\"ts\"\u003e\n    import { Router, Route } from '@svelte-router/core';\n    import NavBar from './lib/NavBar.svelte';\n    import UserView from './lib/UserView.svelte';\n\u003c/script\u003e\n\n\u003cRouter\u003e\n    \u003cNavBar /\u003e\n    \u003cdiv class=\"container\"\u003e\n        \u003c!-- content outside routes is always rendered --\u003e\n        \u003ch1\u003eRouting Demo\u003c/h1\u003e\n        \u003cRoute key=\"users\" path=\"/users\"\u003e\n            \u003c!-- content here --\u003e\n        \u003c/Route\u003e\n        \u003cRoute key=\"user\" path=\"/users/:userId\"\u003e\n            \u003c!-- access parameters via the snippet parameter --\u003e\n            {#snippet children({ rp })}\n                \u003cUserView id={rp?.userId} /\u003e \u003c!-- Intellisense will work here!! --\u003e\n            {/snippet}\n        \u003c/Route\u003e\n        ...\n    \u003c/div\u003e\n\u003c/Router\u003e\n```\n\n### Navigation Links\n\nThe best practice is to render the links inside a router's hierarchy, but this is not mandatory.\n\n```svelte\n\u003c!-- NavBar.svelte --\u003e\n\u003cscript lang=\"ts\"\u003e\n    import { Link } from '@svelte-router/core';\n\u003c/script\u003e\n\n\u003cnav\u003e\n    \u003cdiv class=\"nav-links\"\u003e\n        \u003cul\u003e\n            \u003cli class=\"nav-link\"\u003e\n                \u003cLink href=\"/users\" activeFor=\"users\" activeState={{ class: 'active' }}\n                    \u003eAll Users\u003c/Link\n                \u003e\n            \u003c/li\u003e\n            ...\n        \u003c/ul\u003e\n    \u003c/div\u003e\n\u003c/nav\u003e\n```\n\n---\n\n[Issues Here](https://github.com/WJSoftware/svelte-router/issues)\n\n[Questions, Polls, Show \u0026 Tell, etc. Here](https://github.com/WJSoftware/svelte-router/discussions)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwjsoftware%2Fsvelte-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwjsoftware%2Fsvelte-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwjsoftware%2Fsvelte-router/lists"}