{"id":26221828,"url":"https://github.com/liascode/preact-hashish-router","last_synced_at":"2025-04-17T12:42:01.350Z","repository":{"id":278468499,"uuid":"935044369","full_name":"LiasCode/preact-hashish-router","owner":"LiasCode","description":"Simple preact router with hash and browser routing ","archived":false,"fork":false,"pushed_at":"2025-03-21T19:00:19.000Z","size":97,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T06:11:15.222Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LiasCode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-02-18T20:14:52.000Z","updated_at":"2025-03-21T19:00:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"0dd26593-d86f-47d3-80cf-c9841e13ca45","html_url":"https://github.com/LiasCode/preact-hashish-router","commit_stats":null,"previous_names":["liascode/preact-hashish-router"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiasCode%2Fpreact-hashish-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiasCode%2Fpreact-hashish-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiasCode%2Fpreact-hashish-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiasCode%2Fpreact-hashish-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiasCode","download_url":"https://codeload.github.com/LiasCode/preact-hashish-router/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249342132,"owners_count":21254228,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2025-03-12T16:30:26.946Z","updated_at":"2025-04-17T12:42:01.344Z","avatar_url":"https://github.com/LiasCode.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Preact Hashish Router\n\n## Features\n\n- `hash` and `browser` routing types.\n- Support for lazy-loaded routes (`lazy` loading).\n- Error handling integration with `ErrorRoute`.\n- Fully typed.\n- Ultra lightweight.\n- No external dependencies.\n\n## Installation\n\n```bash\nnpm install preact-hashish-router@latest\n```\n\n## Usage\n\n### Context Setup\n\nFirst, ensure your application is wrapped within the router context. This will allow you to access routes and related functions.\n\n```tsx\nimport { ErrorRoute, Route, Router, RouterErrorBoundary } from \"preact-hashish-router\";\nimport _404 from \"./routes/404\";\nimport AboutPage from \"./routes/About\";\nimport HomePage from \"./routes/Home\";\nimport ProductPage from \"./routes/Product\";\n\nexport default function App() {\n  return (\n    \u003cRouter type=\"hash\"\u003e {/* \u003c-- or browser */}\n      \u003cRouterErrorBoundary\u003e\n        \u003cRoute path=\"/\"\u003e\n          \u003cHomePage /\u003e\n        \u003c/Route\u003e\n\n        \u003cRoute path=\"/about\"\u003e\n          \u003cAboutPage /\u003e\n        \u003c/Route\u003e\n\n        \u003cRoute path=\"/product/:id\"\u003e\n          \u003cProductPage /\u003e\n        \u003c/Route\u003e\n\n        \u003cErrorRoute\u003e\n          \u003c_404 /\u003e\n        \u003c/ErrorRoute\u003e\n      \u003c/RouterErrorBoundary\u003e\n    \u003c/Router\u003e\n  );\n}\n```\n\n### Using the `useRouter` Hook\n\nThe `useRouter` hook gives you access to the router context to programmatically navigate or retrieve information about the current route.\n\n```tsx\nimport { useRouter } from \"preact-hashish-router\";\n\nfunction HomePage() {\n  const router = useRouter();\n\n  function goToAbout() {\n    router.go(\"/about\");\n  }\n\n  return (\n    \u003cdiv\u003e\n      \u003ch1\u003eHome Page\u003c/h1\u003e\n      \u003cbutton onClick={goToAbout}\u003eGo to About\u003c/button\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n### `\u003cA /\u003e` Component for Navigation\n\n```tsx\nimport { A } from \"preact-hashish-router\";\n\nexport default function Header() {\n  return (\n    \u003cheader\u003e\n      \u003cnav\u003e\n        \u003cA href=\"/\"\u003eHome\u003c/A\u003e\n        \u003cA href=\"/about\"\u003eAbout\u003c/A\u003e\n      \u003c/nav\u003e\n    \u003c/header\u003e\n  );\n}\n```\n\n### `\u003cRedirect /\u003e` Component\n\n```tsx\nimport { Redirect } from \"preact-hashish-router\";\n\nexport default function ProductPage() {\n  return (\n    \u003c\u003e\n      \u003cheader\u003e\n        \u003cnav\u003e\n          \u003cA href=\"/\"\u003eHome\u003c/A\u003e\n          \u003cA href=\"/about\"\u003eAbout\u003c/A\u003e\n        \u003c/nav\u003e\n      \u003c/header\u003e\n      \u003cRedirect to=\"/\" /\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n## Development\n\nIf you have any improvements or find any issues, feel free to contribute or open an issue in the associated repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliascode%2Fpreact-hashish-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliascode%2Fpreact-hashish-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliascode%2Fpreact-hashish-router/lists"}