Files
sweet/docs/canary/advanced/app-wrapper.md
T
Marvin Hagemeister a703e79181 docs: update canary docs for Fresh 2 (#3108)
There are still some rough edges here and there, but it's in a much
better shape than what we have today.
2025-07-18 15:18:38 +02:00

34 lines
856 B
Markdown

---
description: |
Add a global app wrapper to provide common meta tags or context for application routes.
---
The app wrapper component is a Preact component that represents the outer
structure of the HTML document, typically up until the `<body>`-tag. It is only
rendered on the server and never on the client. The passed `Component` value
represents the children of this component.
```tsx
function AppWrapper({ Component }) {
return (
<html lang="en">
<head>
<meta charset="utf-8" />
<title>My App</title>
</head>
<body>
<Component />
</body>
</html>
);
}
app.appWrapper(AppWrapper);
```
Every `ctx.render()` call will include the app wrapper component by default,
unless opted out.
Note that only one app wrapper component is supported per
[`App`](/docs/canary/concepts/app) instance.