@extrojs/router
v0.2.0
Published
Hash-based router for Extro: createExtroRouter, Link, useLocation, useParams, useRouter, useSearchParams.
Downloads
52
Maintainers
Readme
@extrojs/router
Hash-based router for Extro. Provides createExtroRouter (wired up for you by the framework), the Link component, and the hooks (useLocation, useParams, useRouter, useSearchParams) used by Chrome extension pages.
Installed automatically as a dependency of extrojs.
Usage
import { Link, useParams, useRouter } from "@extrojs/router"
export default function UserPage() {
const router = useRouter()
const { id } = useParams<{ id: string }>()
return (
<div>
<h1>User {id}</h1>
<Link href="/">Home</Link>
<button onClick={() => router.back()}>Back</button>
</div>
)
}Link renders a real <a href="#/..."> and prepends the # for you, so you never hand-write hash URLs. Pass replace to swap the current history entry instead of pushing a new one.
Docs
License
MIT
