{"id":15369109,"url":"https://github.com/developit/preact-views","last_synced_at":"2025-10-26T02:45:43.576Z","repository":{"id":57329594,"uuid":"82633156","full_name":"developit/preact-views","owner":"developit","description":"📺 Named views for Preact, with easy-as-pie linking between them.","archived":false,"fork":false,"pushed_at":"2020-09-24T19:48:36.000Z","size":6,"stargazers_count":39,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T11:16:10.956Z","etag":null,"topics":["preact","preact-components","preact-router","routing"],"latest_commit_sha":null,"homepage":"https://jsfiddle.net/developit/jz95kc33/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/developit.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-02-21T03:45:44.000Z","updated_at":"2023-07-24T18:53:09.000Z","dependencies_parsed_at":"2022-09-15T21:12:08.558Z","dependency_job_id":null,"html_url":"https://github.com/developit/preact-views","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/developit%2Fpreact-views","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fpreact-views/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fpreact-views/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fpreact-views/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/developit","download_url":"https://codeload.github.com/developit/preact-views/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249081910,"owners_count":21209776,"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":["preact","preact-components","preact-router","routing"],"created_at":"2024-10-01T13:34:13.566Z","updated_at":"2025-10-26T02:45:43.512Z","avatar_url":"https://github.com/developit.png","language":"JavaScript","readme":"# preact-views\n\n[![NPM](http://img.shields.io/npm/v/preact-views.svg)](https://www.npmjs.com/package/preact-views)\n[![travis-ci](https://travis-ci.org/developit/preact-views.svg)](https://travis-ci.org/developit/preact-views)\n\n**Named views for [Preact], with easy-as-pie linking between them!**\n\n`preact-views` provides a `\u003cViews /\u003e` component that renders its children only when their `name` prop is selected as the current \"view\". The current view name can be set via a prop, or automatically through the provided `\u003cLink /\u003e` component.\n\n\u003e **Note:** `preact-views` is simple and does not do orchestration or routing for you. If you're looking for a URL router, try [preact-router](https://github.com/developit/preact-router).\n\n#### [See a Real-world Example :arrow_right:](https://jsfiddle.net/developit/jz95kc33/)\n\n---\n\n\n### Complete Example\n\n```js\nimport { Views, Link } from 'preact-views';\nimport { h, render } from 'preact';\n\nconst Home = () =\u003e (\n\t\u003cdiv\u003e\n\t\t\u003ch1\u003eHome!\u003c/h1\u003e\n\t\t\u003cLink to=\"other\" params={{ value:1 }}\u003eGo Other\u003c/Link\u003e\n\t\u003c/div\u003e\n);\n\nconst Other = ({ value=0 }) =\u003e (\n\t\u003cdiv\u003e\n\t\t\u003ch1\u003eOther.\u003c/h1\u003e\n\t\t\u003cLink to=\"home\"\u003eGo Home\u003c/Link\u003e\n\t\t\u003cp\u003evalue is {value}.\u003c/p\u003e\n\t\t\u003cLink to=\"other\" params={{ value: value+1 }}\u003eIncrement\u003c/Link\u003e\n\t\u003c/div\u003e\n);\n\nrender((\n\t\u003cViews view=\"home\"\u003e\n\t\t\u003cHome name=\"home\" /\u003e\n\t\t\u003cOther name=\"other\" /\u003e\n\t\u003c/Views\u003e\n), document.body);\n```\n\n[**See it running :arrow_right:**](https://jsfiddle.net/developit/jz95kc33/)\n\n\n---\n\n\n### Simple Example\n\n```js\nimport Views from 'preact-views';\nimport { h, render } from 'preact';\n\nrender((\n\t\u003cViews view=\"one\"\u003e\n\t\t\u003cdiv name=\"one\"\u003eone\u003c/div\u003e\n\t\t\u003cdiv name=\"two\"\u003etwo\u003c/div\u003e\n\t\u003c/Views\u003e\n), document.body);\n\n// renders a div containing the text \"one\"\n```\n\n\n---\n\n\n### License\n\n[MIT]\n\n\n[Preact]: https://github.com/developit/preact\n[MIT]: http://choosealicense.com/licenses/mit/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopit%2Fpreact-views","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevelopit%2Fpreact-views","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopit%2Fpreact-views/lists"}