Skip to content

Commit 01ac8b2

Browse files
authored
(Docs) Update type safety for AppLoadContext (remix-run#12861)
* (Docs) Update type safety for AppLoadContext * filename * Update contributors.yml * review feedback
1 parent 228b17e commit 01ac8b2

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

contributors.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
- dauletbaev
7878
- david-bezero
7979
- david-crespo
80+
- davidbielik
8081
- dcblair
8182
- decadentsavant
8283
- dgrijuela

docs/how-to/route-module-type-safety.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,23 @@ If you want to run type checking as its own command — for example, as part of
4545
}
4646
```
4747

48-
## 4. Type-only auto-imports (optional)
48+
## 4. Typing `AppLoadContext`
49+
50+
51+
## Extending app `Context` types
52+
53+
To define your app's `context` type, add the following in a `.td` or `.d.ts` file within your project:
54+
55+
```typescript
56+
import "react-router";
57+
declare module "react-router" {
58+
interface AppLoadContext {
59+
// add context properties here
60+
}
61+
}
62+
```
63+
64+
## 5. Type-only auto-imports (optional)
4965

5066
When auto-importing the `Route` type helper, TypeScript will generate:
5167

0 commit comments

Comments
 (0)