| name | solid-router-alternative |
| description | Solid Router alternative routers: HashRouter for hash-based URLs, MemoryRouter for testing and in-memory navigation. |
| metadata | {"globs":["**/*router*"]} |
Alternative Routers
HashRouter
Uses hash portion of URL for routing. Client-side only routing (hash not handled by server).
import { HashRouter, Route } from "@solidjs/router";
<HashRouter root={App}>
<Route path="/" component={Home} />
<Route path="/about" component={About} />
</HashRouter>
Use cases:
- Legacy hash-based URLs
- Client-side only applications
- No server routing needed
URL format: https://example.com/#/about
MemoryRouter
Keeps router history in memory. Doesn't interact with browser URL. Useful for testing.
import { MemoryRouter, Route } from "@solidjs/router";
<MemoryRouter root={App}>
<Route path="/" component={Home} />
<Route path="/about" component={About} />
</MemoryRouter>
Use cases:
- Testing router logic
- Controlling router state programmatically
- Testing without browser URL changes
Note: URL in address bar won't change, but router state changes.
Best Practices
- Use
HashRouter for legacy compatibility or client-only apps
- Use
MemoryRouter for testing router behavior
- Default
Router is preferred for most applications (uses pathname)
- All routers support same route configuration and features