Skip to content

Commit c5ad718

Browse files
committed
docs
1 parent db12fc3 commit c5ad718

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/docs/basics/routes.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,24 @@ Response onRequest(RequestContext context, String userId, String postId) {
416416
}
417417
```
418418

419+
## Wildcard Routes ♾
420+
421+
Dart Frog supports wildcard routes. For example, if you create a file called `routes/posts/[...page].dart`, then it will be accessible at any path that starts with `/posts/`, with any number of levels, allowing it to called from `/posts/today`, `/posts/features/stared` and so on and so forth.
422+
423+
Routing parameters are forwarded to the `onRequest` method as seen below.
424+
425+
```dart
426+
import 'package:dart_frog/dart_frog.dart';
427+
428+
Response onRequest(RequestContext context, String page) {
429+
return Response(body: 'post page: $page');
430+
}
431+
```
432+
433+
```warning
434+
Given its nature, wildcard routes **must** be unique leaf routes on their route node, meaning that they need to be a file, and they need to be the only route on their folder.
435+
```
436+
419437
## Route Conflicts 💥
420438

421439
When defining routes, it's possible to encounter route conflicts.

0 commit comments

Comments
 (0)