-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
68 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,43 @@ | ||
# dsf | ||
# Typesafe Routes | ||
|
||
## Quickstart | ||
|
||
### 1. Dependency Installation | ||
``` sh | ||
npm install typesafe-routes | ||
``` | ||
|
||
### 2. Route Tree Definition | ||
|
||
``` js | ||
import { createRoutes, int } from "typesafe-routes"; | ||
|
||
const routes = createRoutes({ | ||
groups: { | ||
path: ["groups", int("gid")], | ||
children: { | ||
users: { | ||
path: ["users", int("uid").optional], | ||
} | ||
} | ||
} | ||
}); | ||
``` | ||
|
||
### 3. Path Rendering | ||
|
||
``` js | ||
// only required param | ||
routes.render("groups/users", { | ||
path: { gid: 123 }, | ||
}); // => "/groups/123/users" | ||
|
||
// with optional param | ||
routes.render("groups/users", { | ||
path: { gid: 123, uid: 456 }, | ||
}); // => "/groups/123/users/456" | ||
``` | ||
|
||
### 4. Discover More Features | ||
|
||
To access the other examples, use the navigation on the left (if on mobile, click the burger icon in the bottom left corner). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters