{"_id":"@coheia/simple-router","_rev":"3-8a3b2cb775c42db5c9c1a56aabb5b3fc","name":"@coheia/simple-router","dist-tags":{"latest":"2.0.0"},"versions":{"0.0.1":{"name":"@coheia/simple-router","version":"0.0.1","description":"A Vanilla SPA Router","author":{"name":"Felipe Correia"},"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"prepublish":"tsc","publish:patch":"npm run prepublish && npm version patch && npm publish","publish:minor":"npm run prepublish && npm version minor && npm publish"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"devDependencies":{"@types/node":"^18.13.0","typescript":"^5.1.5"},"keywords":["router","vanilla","spa","typescript","javascript","front-end"],"tags":["router","vanilla","spa","front-end","typescript","javascript"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/coheia/simple-router.git"},"gitHead":"012653d7527d8a9c8482f25739478d2d7f299d37","bugs":{"url":"https://github.com/coheia/simple-router/issues"},"homepage":"https://github.com/coheia/simple-router#readme","_id":"@coheia/simple-router@0.0.1","_nodeVersion":"18.15.0","_npmVersion":"9.5.0","dist":{"integrity":"sha512-AA98WASON/whLvU3GrNAqg43gsjAx6n2DmW1PA+U/yryXckZW30inGNme9nCCf9L4iVL2hBwH0wwOv/31BHTLQ==","shasum":"7cd8aa6e7e788d71aeafad412e26e3b733c09eb7","tarball":"https://registry.npmjs.org/@coheia/simple-router/-/simple-router-0.0.1.tgz","fileCount":9,"unpackedSize":8439,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHrblXOgq3woaV8TyBZULP2UuGuo3ngKt3ytO//sLRxlAiBrXVSAiLIL5bMLGULBkCnGoErkSiaZWaMVHtsFANIMpg=="}]},"_npmUser":{"name":"coheia","email":"coheia.dev@gmail.com"},"directories":{},"maintainers":[{"name":"coheia","email":"coheia.dev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-router_0.0.1_1688420454427_0.803391001807781"},"_hasShrinkwrap":false},"1.0.0":{"name":"@coheia/simple-router","version":"1.0.0","description":"A Vanilla SPA Router","author":{"name":"Felipe Correia"},"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"prepublish":"tsc","publish:major":"npm run prepublish && npm version major && npm publish","publish:patch":"npm run prepublish && npm version patch && npm publish","publish:minor":"npm run prepublish && npm version minor && npm publish"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"devDependencies":{"@types/node":"^18.13.0","typescript":"^5.1.5"},"keywords":["router","vanilla","spa","typescript","javascript","front-end"],"tags":["router","vanilla","spa","front-end","typescript","javascript"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/coheia/simple-router.git"},"gitHead":"fe16d3c05e3b9ac4263669693ab6e470ab223afe","bugs":{"url":"https://github.com/coheia/simple-router/issues"},"homepage":"https://github.com/coheia/simple-router#readme","_id":"@coheia/simple-router@1.0.0","_nodeVersion":"18.16.1","_npmVersion":"9.7.2","dist":{"integrity":"sha512-rOEtspzvBBhHurPoKLhnzqENPlSw3NAdRQ3uG9PAsVQCCxUufIdoFOu3b+D7u4cPRQmSi0HJtod70phZueN0LA==","shasum":"ffcd5a05fe0e91c207b6002f6a6a6dc06c4e90ae","tarball":"https://registry.npmjs.org/@coheia/simple-router/-/simple-router-1.0.0.tgz","fileCount":9,"unpackedSize":7980,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCWR5GeNvNgKs+H6emiRB1+18jLmQx/IPiP+ZZ/FuYG7wIhAKZedu7yAPxAXFsdIf4YfzdRfJZ45INElLNjwBiF90ZI"}]},"_npmUser":{"name":"coheia","email":"coheia.dev@gmail.com"},"directories":{},"maintainers":[{"name":"coheia","email":"coheia.dev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-router_1.0.0_1688484828989_0.7655301191250856"},"_hasShrinkwrap":false},"1.1.0":{"name":"@coheia/simple-router","version":"1.1.0","description":"A Vanilla SPA Router","author":{"name":"Felipe Correia"},"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"prepublish":"tsc","publish:major":"npm run prepublish && npm version major && npm publish","publish:patch":"npm run prepublish && npm version patch && npm publish","publish:minor":"npm run prepublish && npm version minor && npm publish"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"devDependencies":{"@types/node":"^18.13.0","typescript":"^5.1.5"},"keywords":["router","vanilla","spa","typescript","javascript","front-end"],"tags":["router","vanilla","spa","front-end","typescript","javascript"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/coheia/simple-router.git"},"gitHead":"5af67d9655a630836d242a077b87ee46a12d552a","bugs":{"url":"https://github.com/coheia/simple-router/issues"},"homepage":"https://github.com/coheia/simple-router#readme","_id":"@coheia/simple-router@1.1.0","_nodeVersion":"18.15.0","_npmVersion":"9.5.0","dist":{"integrity":"sha512-aVV1C0p//TMdy6OJC8MEBv0BIqLp9kRCajRwB42lV4rbUU9SBMq1HYhLUAhZk19RnLfe4Chwxh7K15wAMwhTuw==","shasum":"1bde6eafc798177f5a4bc42c23407c753d26b922","tarball":"https://registry.npmjs.org/@coheia/simple-router/-/simple-router-1.1.0.tgz","fileCount":9,"unpackedSize":8004,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHdhjUW4LwEGs/vF9YgOeelKvJ+68CSFWxgHO6xOCCccAiEAzjNw07G7OFmNHvJBTTPkRMTSdq4EFrJrRgjB5kJgV3E="}]},"_npmUser":{"name":"coheia","email":"coheia.dev@gmail.com"},"directories":{},"maintainers":[{"name":"coheia","email":"coheia.dev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-router_1.1.0_1688678595779_0.3695480272149043"},"_hasShrinkwrap":false},"2.0.0":{"name":"@coheia/simple-router","version":"2.0.0","description":"A Vanilla SPA Router","author":{"name":"Felipe Correia"},"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"prepublish":"tsc","publish:major":"npm run prepublish && npm version major && npm publish","publish:patch":"npm run prepublish && npm version patch && npm publish","publish:minor":"npm run prepublish && npm version minor && npm publish"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"devDependencies":{"@types/node":"^18.13.0","typescript":"^5.1.5"},"keywords":["router","vanilla","spa","typescript","javascript","front-end"],"tags":["router","vanilla","spa","front-end","typescript","javascript"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/coheia/simple-router.git"},"gitHead":"68018774598fb1fe8d798d9f51cd0825a4b2fab4","bugs":{"url":"https://github.com/coheia/simple-router/issues"},"homepage":"https://github.com/coheia/simple-router#readme","_id":"@coheia/simple-router@2.0.0","_nodeVersion":"18.15.0","_npmVersion":"9.5.0","dist":{"integrity":"sha512-VAwXxxFessdueYo+uNOi5mKLBVJQBipspco2A71ppiu3dwImonfS6zNQ41b8Eg+N6xyMF7F5TSlkw4xt2p4LaA==","shasum":"734a27bfefdc3cee2c4c43695df47bba0f4a0822","tarball":"https://registry.npmjs.org/@coheia/simple-router/-/simple-router-2.0.0.tgz","fileCount":11,"unpackedSize":13211,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC2oS/D9QHE8f8j+kTanDhN6V4kCfct0vsblCGWsBt7fAiByUCII8CqTULmctPlGGw//4MdrekzXKsOSehWr8mtJVg=="}]},"_npmUser":{"name":"coheia","email":"coheia.dev@gmail.com"},"directories":{},"maintainers":[{"name":"coheia","email":"coheia.dev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-router_2.0.0_1688860497744_0.5137884864013293"},"_hasShrinkwrap":false}},"time":{"created":"2023-07-03T21:40:54.353Z","0.0.1":"2023-07-03T21:40:54.591Z","modified":"2023-07-08T23:54:58.072Z","1.0.0":"2023-07-04T15:33:49.168Z","1.1.0":"2023-07-06T21:23:15.933Z","2.0.0":"2023-07-08T23:54:57.901Z"},"maintainers":[{"name":"coheia","email":"coheia.dev@gmail.com"}],"description":"A Vanilla SPA Router","homepage":"https://github.com/coheia/simple-router#readme","keywords":["router","vanilla","spa","typescript","javascript","front-end"],"repository":{"type":"git","url":"git+https://github.com/coheia/simple-router.git"},"author":{"name":"Felipe Correia"},"bugs":{"url":"https://github.com/coheia/simple-router/issues"},"license":"MIT","readme":"# **Simple Router**\r\n\r\n![npm](https://img.shields.io/npm/v/@coheia/simple-router)\r\n![npm bundle size](https://img.shields.io/bundlephobia/min/@coheia/simple-router?color=1bbfc1)\r\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/@coheia/simple-router?color=1bbfc1)\r\n![npm](https://img.shields.io/npm/dt/@coheia/simple-router?color=6d9c29)\r\n\r\nA router for Vanilla Single Page Application.\r\n\r\n## Table of Contents\r\n\r\n- [Installation](#installation)\r\n- [Import](#import)\r\n- [Usage](#usage)\r\n- [Contributing](#contributing)\r\n- [License](#license)\r\n\r\n### **Installation**\r\n\r\n```console\r\n$ npm install @coheia/simple-router\r\n```\r\n\r\n### **Import**\r\n\r\nImport the SimpleRouter class and its related types as follow:\r\n\r\n```typescript\r\nimport SimpleRouter from \"@coheia/simple-router\";\r\n```\r\n\r\n### **Usage**\r\n\r\n```typescript\r\nimport SimpleRouter, { defineRenderMethod } from \"@coheia/simple-router\";\r\n\r\n// The following imports are not provided by SimpleRouter:\r\nimport NotFound from \"../pages/404/404\"; // Component for page NotFound\r\nimport Home from \"../pages/Home/Home\"; // Component for page Home\r\nimport Contact from \"../pages/Contact/Contact\"; // Component for page Contact\r\nimport Blog from \"../pages/Blog/Blog\"; // Component for page Blog\r\nimport Article from \"../pages/Blog/Article\"; // Component for page Article\r\nimport type { Page } from \"./Page\"; // The type of the component\r\nimport { render } from \"./render\"; // SPA Render Method\r\n\r\n// Step 1: Define the render method for the SPA\r\nconst renderMethod = defineRenderMethod<Page>(async (route) => {\r\n  const page = route.component();\r\n  render(await page.render(), \"#router\");\r\n});\r\n\r\n// Step 2: Create an instance of SimpleRouter\r\nconst router = new SimpleRouter<Page>(renderMethod, new NotFound());\r\n\r\n// Step 3: Add routes to the router\r\nrouter.addRoute(\"/\", () => new Home());\r\nrouter.addRoute(\"/contact\", () => new Contact());\r\nrouter.addRoute(\"/blog\", () => new Blog());\r\nrouter.addRoute(\"/blog/[slug]\", (params) => new Article(params));\r\n\r\n// Step 4: Start the router\r\nrouter.start();\r\n```\r\n\r\n### **Contributing**\r\n\r\nYour contributions are always welcome! Submit a pull request with your changes or create an issue to discuss anything.\r\n\r\n### **License**\r\n\r\nThis package is licensed under the MIT License.\r\n","readmeFilename":"README.md"}