Hooks
Swift Rust works with the standard React hooks. There are no framework-specific hooks beyond the React core.
useRouter
Access the current route and navigate programmatically.
usage
"use client";
import { useRouter } from "swift-rust/router";
export function Component() {
const router = useRouter();
return <button onClick={() => router.push("/dashboard")}>Go</button>;
}usePathname
Get the current URL path.
usage
"use client";
import { usePathname } from "swift-rust/router";
export function NavLink({ href, children }) {
const pathname = usePathname();
const active = pathname === href;
return <a href={href} aria-current={active ? "page" : undefined}>{children}</a>;
}useSearchParams
Read the current URL's search params.
usage
"use client";
import { useSearchParams } from "swift-rust/router";
export function Component() {
const params = useSearchParams();
return <p>Query: {params.get("q")}</p>;
}