{"id":13727114,"url":"https://github.com/kruschid/typesafe-routes","last_synced_at":"2025-04-03T23:12:05.693Z","repository":{"id":34460554,"uuid":"179262693","full_name":"kruschid/typesafe-routes","owner":"kruschid","description":"Spices up your favorite routing library by adding type safety to plain string-based route definitions.","archived":false,"fork":false,"pushed_at":"2024-10-04T09:35:02.000Z","size":3006,"stargazers_count":102,"open_issues_count":3,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-12T01:17:06.697Z","etag":null,"topics":["angular-router","react-router","typesafe-routes","typescript","vue-router"],"latest_commit_sha":null,"homepage":"https://kruschid.github.io/typesafe-routes/","language":"TypeScript","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/kruschid.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-03T10:02:07.000Z","updated_at":"2024-10-04T09:34:58.000Z","dependencies_parsed_at":"2023-11-28T17:48:25.425Z","dependency_job_id":"3828e0cc-883c-4057-bab5-34281617b123","html_url":"https://github.com/kruschid/typesafe-routes","commit_stats":{"total_commits":258,"total_committers":8,"mean_commits":32.25,"dds":0.4767441860465116,"last_synced_commit":"83535e7ed269a1d8b86860d9950a5600df58a979"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kruschid%2Ftypesafe-routes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kruschid%2Ftypesafe-routes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kruschid%2Ftypesafe-routes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kruschid%2Ftypesafe-routes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kruschid","download_url":"https://codeload.github.com/kruschid/typesafe-routes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247092396,"owners_count":20882218,"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":["angular-router","react-router","typesafe-routes","typescript","vue-router"],"created_at":"2024-08-03T01:03:39.954Z","updated_at":"2025-04-03T23:12:05.664Z","avatar_url":"https://github.com/kruschid.png","language":"TypeScript","funding_links":["https://www.buymeacoffee.com/kruschid"],"categories":["TypeScript"],"sub_categories":[],"readme":"![minzipped size](https://badgen.net/bundlephobia/minzip/typesafe-routes)\n![minified size](https://badgen.net/bundlephobia/min/typesafe-routes)\n![tree shaking](https://badgen.net/bundlephobia/tree-shaking/typesafe-routes)\n[![discord link](https://img.shields.io/badge/Chat%20on-Discord-%235865f2)](https://discord.gg/BCGmvSSJBk)\n\n# Typesafe Routes\n\n`typesafe-routes` speeds up app development and cuts down on testing efforts by letting TypeScript catch route and parameter type inconsistencies. Your code will be more robust, making broken links a thing of the past.\n\n`typesafe-routes` features include:\n\n- Autocompletion for paths and parameters \n- Path \u0026 template rendering\n- Nested, absolute, and relative path rendering\n- Parameter parsing and serialization\n- Type-safe, customizable, and extendable\n- Compatible with JavaScript (apart from type safety)\n- Small bundle size starting at less than 1kb\n\n## Example\n\n[typescript playground](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgYygUwIYzQJQgV2wGcAaOYAOxjPQoBM0oAFLACzLAyiLRZnbjZwAGyxo4AXzgAzKBBBwARDACeYNEQzS0AWjmENigNwBYAFDmA9Jbj7sg9OIbTKwGMAgVzyT0Xh2NOABeFHQxPAMiAAoEczg4fB5uAC5EOPi4Tn5UgG1FRMYiRTJKGCj84DpFAEoAXTIM6zhLAu5LZPxK9PjkVmBhOlpU2LMMjLQ6N2HMtlzFCbdFWskGxpsWpKJ2zrpLBZhujIZhNGxprNY549O0JZXm9datjsrLa+xDiXSvswlq0wsZiaGAARkQIMIDDN+ERzLQGMw2FEAkQAHRPMhIHapACMACYAMySf4POAAPwAfEoNoVLPiCYpzFYbBQNNg6NDWLCzPDGHxWMiCMR0ZtUftMQlKrjCcSjKTKdSnnTCXtJjBGTy0PQ+UiUSLCqj3mgJdi4PTZfKqYoaW16W80CdsBrmbYHVhgAA3cQXIhwcoAfUU5HowGQYl9-HEfi47goAHM4Dw4yAtTBqnCtQj+YLIqj-fruCapWaZX85U0FflNsqGRntYj+DnhU882K1Ziy5alPtnUCbJxuN62DMoBgQNyBzxs3qW+LEJK6KlFAAWPFBzsVqlY4uryTmSe8XVCjQFtFz61KgCcl9VixJm-npuve8BTSEYFExDg5nfn7QTZPWc1XvGxKxtZ4dlvdUfzQEQxAAtF8yAtwQPJK0lReXYexguDsAQ09W32VDKx7IA)\n\n``` ts\nimport { createRoutes, int, renderPath, parsePath, template } from \"typesafe-routes\";\n\n// route tree definition\nconst routes = createRoutes({\n  users: {\n    path: [\"users\", int(\"uid\")],    // /users/:uid\n    children: {\n      edit: { path: [\"edit\"] },     // /users/:uid/edit\n      delete: { path: [\"delete\"] }, // /users/:uid/delete\n    }\n  }\n});\n\n// absolute paths\nrenderPath(routes.users, { uid: 123 }); // ~\u003e \"/users/123\"\n\n// nested paths\nrenderPath(routes.users.edit, { uid: 123 }); // ~\u003e \"/users/123/edit\"\nrenderPath(routes.users.delete, { uid: 123 }); // ~\u003e \"/users/123/delete\"\n\n// relative paths (\"_\" indicates the starting segment)\nrenderPath(routes._.users, { uid: 123 }); // ~\u003e \"users/123\"\nrenderPath(routes.users._.edit, {}); // ~\u003e \"edit\"\n\n// parse path params\nparsePath(routes.users.edit, { uid: \"42\" }); // ~\u003e { uid: 42 }\nparsePath(routes.users.edit, \"/users/99/edit\"); // ~\u003e { uid: 99 }\n\n// templates \ntemplate(routes.users.edit); // ~\u003e \"/users/:uid/edit\"\ntemplate(routes._.users.edit); // ~\u003e \"users/:uid/edit\"\ntemplate(routes.users._.edit); // ~\u003e \"edit\"\n```\n\n## Quick Reference\n\nThe complete [documentation can be found here](https://kruschid.github.io/typesafe-routes).\n\n- Functions\n  - `renderPath`: renders a path with parameters\n  - `renderQuery`: renders a search query\n  - `render`: renders a path with parameters including query string\n  - `template`: renders a route template\n  - `parsePath`: parses dynamic segments in a path\n  - `parseQuery`: parses parameters in a search query\n  - `parse`: parses path and search query for parameters\n  - `replace`: partially replaces dynamic segments and query params in a string-based path (i.e. `location.path`)\n  \n## Installation\n\n``` sh\nnpm i typesafe-routes # or any npm alternative\n```\n\n## How to Contribute\n\n- leave a star ⭐\n- report a bug 🐞\n- open a pull request 🏗️\n  - please discuss your idea on github or discord **before you start working on your PR**\n- help others ❤️\n- [buy me a coffee ☕](https://www.buymeacoffee.com/kruschid)\n  \n\u003ca href=\"https://www.buymeacoffee.com/kruschid\" target=\"_blank\"\u003e\u003cimg width=\"200px\" src=\"https://cdn.buymeacoffee.com/buttons/v2/default-orange.png\" alt=\"Buy Me A Coffee\" \u003e\u003c/a\u003e\n\n## Roadmap\n  \n- v10-v12 migration guide\n- v12beta-v12.1 migration guide\n- check for duplicate param names in the route tree\n- customizable parsing of search params (for example with qs)\n- demos \u0026 utils\n  - react-router\n  - wouter\n  - vue router\n  - angular router\n  - refinejs\n\n## Docs\n\n- [x] quickstart\n- basic-features\n  - [x] absolute-routes\n  - [x] parameters\n  - [x] nested-routes\n  - [x] relative-routes\n  - [x] route-templates\n  - [x] parameter-parsing\n  - [x] parameter-binding\n  - [x] parameter-types\n- advanced-features\n  - [x] replace-dynamic-segments\n  - [x] global-query-parameters\n- customization\n  - [x] custom-parameter-types\n- tutorials\n  - [x] angular router\n  - [ ] react router\n  - [ ] wouter\n  - [ ] vue router\n  - [ ] refine\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkruschid%2Ftypesafe-routes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkruschid%2Ftypesafe-routes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkruschid%2Ftypesafe-routes/lists"}