{"id":21874778,"url":"https://github.com/dpck/router","last_synced_at":"2025-07-31T12:11:39.808Z","repository":{"id":57107566,"uuid":"169545727","full_name":"dpck/router","owner":"dpck","description":"The Preact Router Component For Compilation With Depack.","archived":false,"fork":false,"pushed_at":"2019-05-14T14:29:27.000Z","size":179,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T22:07:17.209Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://artd.eco/depack","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dpck.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-07T09:15:16.000Z","updated_at":"2019-05-14T14:29:29.000Z","dependencies_parsed_at":"2022-08-20T17:11:07.380Z","dependency_job_id":null,"html_url":"https://github.com/dpck/router","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpck%2Frouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpck%2Frouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpck%2Frouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpck%2Frouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dpck","download_url":"https://codeload.github.com/dpck/router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244881293,"owners_count":20525624,"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":"2024-11-28T07:13:19.196Z","updated_at":"2025-03-21T23:22:02.053Z","avatar_url":"https://github.com/dpck.png","language":"JavaScript","readme":"# @depack/router\n\n[![npm version](https://badge.fury.io/js/%40depack%2Frouter.svg)](https://npmjs.org/package/@depack/router)\n\n`@depack/router` is The Preact Router Component For Compilation With Depack.\n\n```sh\nyarn add -E @depack/router\n```\n\nThe original source code is from [preact-router](https://github.com/developit/preact-router) but it was modified to be able to compile front-ends that use it with Depack using Google Closure Compiler.\n\n**DEMO**: https://dpck.github.io/router/\n\n\u003e *Connect your Preact components up to that address bar.*\n\n\u003e `preact-router` provides a \u003cRouter /\u003e component that conditionally renders its children when the URL matches their path. It also automatically wires up \u003ca /\u003e elements to the router.\n\n## Table Of Contents\n\n- [Table Of Contents](#table-of-contents)\n- [API](#api)\n- [Router](#router)\n- [Copyright](#copyright)\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\u003cimg src=\".documentary/section-breaks/0.svg?sanitize=true\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n## API\n\nThe package is available by importing its default function and named functions:\n\n```js\nimport Router, { Link } from '@depack/router'\n```\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\u003cimg src=\".documentary/section-breaks/1.svg?sanitize=true\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n## Router\n\n```jsx\nimport Router, { Link } from '@depack/router'\nimport { render } from 'preact'\n\nconst Main = () =\u003e (\n  \u003cdiv\u003e\n    \u003cul\u003e\n      \u003cli\u003e\u003cLink href=\"/router/\"\u003eHome\u003c/Link\u003e\u003c/li\u003e\n      \u003cli\u003e\u003cLink href=\"/about\"\u003eAbout\u003c/Link\u003e\u003c/li\u003e\n      \u003cli\u003e\u003cLink href=\"/search/example/hello\"\u003eSearch\u003c/Link\u003e\u003c/li\u003e\n    \u003c/ul\u003e\n    \u003cRouter onChange={(e) =\u003e {\n      if (e.current \u0026\u0026 e.current.attributes.title) {\n        document.title = e.current.attributes.title\n      }\n    }}\u003e\n      \u003cHome path=\"/router/\" title=\"@depack/router\" /\u003e\n      \u003cAbout path=\"/about\" title=\"About\" /\u003e\n      \u003cSearch path=\"/search/:query/:optional?\" title=\"Search\" /\u003e\n    \u003c/Router\u003e\n  \u003c/div\u003e\n)\n\nconst Home = () =\u003e (\u003cdiv\u003e\n  \u003ch3\u003eHome\u003c/h3\u003e\n  Preact Router For Depack.\n\u003c/div\u003e)\nconst About = () =\u003e (\u003cdiv\u003e\n  \u003ch3\u003eAbout\u003c/h3\u003e\n  \u003cp\u003e\u003cem\u003ePreact\u003c/em\u003e is a library for making single-page\n  websites and rendering JSX components.\u003c/p\u003e\n  \u003cp\u003e\u003cem\u003eDepack\u003c/em\u003e is front-end bundler that uses Google\n  Closure Compiler (as well as back-end package compiler).\u003c/p\u003e\n\u003c/div\u003e)\nconst Search = ({ optional }) =\u003e (\u003cdiv\u003e\n  \u003ch3\u003eSearch\u003c/h3\u003e\n  {optional ? `You've searched for: ${optional}` : ''}\n\u003c/div\u003e)\n\nrender(\u003cMain /\u003e, document.querySelector('#preact'))\n```\nIf there is an error rendering the destination route, a 404 will be displayed.\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\u003cimg src=\".documentary/section-breaks/2.svg?sanitize=true\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n## Copyright\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003cth\u003e\n      \u003ca href=\"https://artd.eco\"\u003e\n        \u003cimg src=\"https://raw.githubusercontent.com/wrote/wrote/master/images/artdeco.png\" alt=\"Art Deco\" /\u003e\n      \u003c/a\u003e\n    \u003c/th\u003e\n    \u003cth\u003e\n      © \u003ca href=\"https://artd.eco\"\u003eArt Deco\u003c/a\u003e for \u003ca href=\"https://artd.eco/depack\"\u003eDepack\u003c/a\u003e\n      2019\n    \u003c/th\u003e\n    \u003cth\u003e\n      \u003ca href=\"https://www.technation.sucks\" title=\"Tech Nation Visa\"\u003e\n        \u003cimg src=\"https://raw.githubusercontent.com/artdecoweb/www.technation.sucks/master/anim.gif\" alt=\"Tech Nation Visa\" /\u003e\n      \u003c/a\u003e\n    \u003c/th\u003e\n    \u003cth\u003e\n      \u003ca href=\"https://www.technation.sucks\"\u003eTech Nation Visa Sucks\u003c/a\u003e\n    \u003c/th\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\u003cimg src=\".documentary/section-breaks/-1.svg?sanitize=true\"\u003e\u003c/a\u003e\u003c/p\u003e","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdpck%2Frouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdpck%2Frouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdpck%2Frouter/lists"}