-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 changed file
with
26 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Fastify encapsulation contexts | ||
|
||
## Overview | ||
One of the main features of Fastify is its support for different [encapsulation contexts](https://www.fastify.io/docs/latest/Encapsulation/), the context at which a route is registered determines which hooks, plugins, and decorators are available to it. | ||
|
||
For `fastify-renderer`, contexts are used to allow more customization and configuration for `vite` rendering options. | ||
|
||
More specifically, it is possible to provide a custom `layout` to be used for rendering routes in a specific context. | ||
|
||
*Note: Providing a different `layout` requires that you specifiy a new `base` as well.* | ||
|
||
## Navigating between contexts | ||
Since the router instance is only aware of routes in the current context, navigating to a route in a different context requires bypassing the router. | ||
|
||
This can be done in a couple of ways: | ||
1. Using a `<Link>` tag but specifying the href property as an absolute path by prefixing it with a `~` | ||
2. Using an `<a>` tag instead of a `<Link>` tag from `wouter` | ||
|
||
## Example | ||
|
||
```html | ||
<!-- The router requests the page from the server --> | ||
<Link href="~/">Home</Link> | ||
<!-- The browser requests the page from the server without going through the router --> | ||
<a href="/">Home</a> | ||
``` |