{"id":20863472,"url":"https://github.com/simplr/simplr-router-preact-middleware","last_synced_at":"2025-06-14T15:41:25.418Z","repository":{"id":134792687,"uuid":"328606871","full_name":"Simplr/simplr-router-preact-middleware","owner":"Simplr","description":"A Middleware for Simplr Router to enable Preact support.","archived":false,"fork":false,"pushed_at":"2021-01-18T08:11:32.000Z","size":423,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-19T08:15:40.380Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/Simplr.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":"2021-01-11T09:09:42.000Z","updated_at":"2021-01-18T08:11:35.000Z","dependencies_parsed_at":"2023-05-11T18:32:07.155Z","dependency_job_id":null,"html_url":"https://github.com/Simplr/simplr-router-preact-middleware","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Simplr%2Fsimplr-router-preact-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Simplr%2Fsimplr-router-preact-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Simplr%2Fsimplr-router-preact-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Simplr%2Fsimplr-router-preact-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Simplr","download_url":"https://codeload.github.com/Simplr/simplr-router-preact-middleware/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243236589,"owners_count":20258870,"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-18T05:29:11.749Z","updated_at":"2025-03-12T14:43:52.928Z","avatar_url":"https://github.com/Simplr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Title Image](simplr-router-title-image.png)\n\n# Simplr-Router Preact Middleware\n\n## Introduction\n\nThis repository contains the Preact middleware needed for running [Simplr Router](https://github.com/Simplr/simplr-router) with Preact.\n\n## Usage\n\nThe example is created on top of Preact cli create default.\n\n```javascript\nimport Header from \"./header\";\n\nimport Home from \"../routes/home\";\nimport Profile from \"../routes/profile\";\nimport SimplrRouter from \"@simplr-wc/router\";\nimport SimplrRouterPreactMiddleware from \"@simplr-wc/router-preact-middleware\";\n\nconst routes = [\n  {\n    path: \"/\",\n    component: Home,\n  },\n  {\n    path: \"profile\",\n    component: Profile,\n    routes: [\n      {\n        path: \":user\",\n        component: Profile,\n      },\n    ],\n  },\n];\n\nconst router = new SimplrRouter({ routes });\nrouter.use(SimplrRouterPreactMiddleware());\nrouter.init();\n\nconst App = () =\u003e (\n  \u003cdiv id=\"app\"\u003e\n    \u003cHeader /\u003e\n  \u003c/div\u003e\n);\n\nexport default App;\n```\n\nThe properties from dynamic routes are accessible from the props of the component.\n\n```javascript\nimport { h } from \"preact\";\nimport { useEffect, useState } from \"preact/hooks\";\nimport style from \"./style.css\";\n\n// Note: `user` comes from the URL, courtesy of our router\nconst Profile = ({ user }) =\u003e {\n  const [time, setTime] = useState(Date.now());\n  const [count, setCount] = useState(10);\n\n  useEffect(() =\u003e {\n    let timer = setInterval(() =\u003e setTime(Date.now()), 1000);\n    return () =\u003e clearInterval(timer);\n  }, []);\n\n  return (\n    \u003cdiv class={style.profile}\u003e\n      \u003ch1\u003eProfile: {user}\u003c/h1\u003e\n      \u003cp\u003eThis is the user profile for a user named {user}.\u003c/p\u003e\n\n      \u003cdiv\u003eCurrent time: {new Date(time).toLocaleString()}\u003c/div\u003e\n\n      \u003cp\u003e\n        \u003cbutton onClick={() =\u003e setCount((count) =\u003e count + 1)}\u003eClick Me\u003c/button\u003e{\" \"}\n        Clicked {count} times.\n      \u003c/p\u003e\n    \u003c/div\u003e\n  );\n};\n\nexport default Profile;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplr%2Fsimplr-router-preact-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimplr%2Fsimplr-router-preact-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplr%2Fsimplr-router-preact-middleware/lists"}