Skip to content

Commit

Permalink
docs(labs): add typed routes (#4582)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery committed Jun 23, 2023
1 parent 89b4fea commit 941b4f2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
44 changes: 44 additions & 0 deletions packages/docs/src/routes/docs/labs/typed-routes/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: 🧪 Typed Routes
contributors:
- mhevery
---

# 🧪 Typed Routes
**Stage:** `prototyping`

Provides type safe way of building URLs within the application.

## Installation

1. `npm install github:BuilderIo/qwik-labs-build#main`
2. update `vite.config.js`
```typescript
// ...
import { qwikTypes } from '@builder.io/qwik-labs/vite';

export default defineConfig(() => {
return {
plugins: [
// ...
qwikTypes() // <== Add `qwikTypes()` to the list of plugins
],
// ...
};
});
```
3. Run build so that it generates `~/routes.gen.d.ts` and `~/routes.config.tsx` files.
3. To create a typesafe link:
```typescript
import { AppLink } from '~/routes.config';

export default component$(() => {
// ...
return (
// ...
<AppLink route="/your/[appParam]/link/" param:appParam={"some-value"}>
Link text
</AppLink>
);
});
```
1 change: 1 addition & 0 deletions packages/docs/src/routes/docs/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

- [Overview](/docs/labs/index.mdx)
- [Insights](/docs/labs/insights/index.mdx)
- [Typed Routes](/docs/labs/typed-routes/index.mdx)

## Integrations

Expand Down

0 comments on commit 941b4f2

Please sign in to comment.