---
description: |
The app wrapper defines the outermost HTML shell shared by all pages - the ,
, and tags.
---
The app wrapper is the outermost component in Fresh's rendering hierarchy. It
defines the ``, ``, and `` tags that every page shares. It is
only rendered on the server.
## When to use an app wrapper
Use an app wrapper when you need to:
- Set the document language (``)
- Include global `` tags, fonts, or stylesheets
- Add analytics scripts or structured data to every page
- Set a global `` class or data attribute
- Provide a consistent HTML skeleton without repeating it in every layout
If you're using [file-based routing](/docs/concepts/file-routing), create a
`routes/_app.tsx` file. Otherwise, register it programmatically with
`app.appWrapper()`.
## Basic example
```tsx routes/_app.tsx
import { define } from "../utils.ts";
export default define.page(({ Component, url }) => {
return (
My App
);
});
```
## Programmatic registration
When building your app with `new App()` instead of file-based routing:
```tsx
function AppWrapper({ Component }) {
return (
My App
);
}
app.appWrapper(AppWrapper);
```
Only one app wrapper is supported per [`App`](/docs/concepts/app) instance.
## How it fits in the render hierarchy
When Fresh renders a page, the components nest like this:
1. **App wrapper** (`_app.tsx`) - outermost, provides ``/``/``
2. **[Layouts](/docs/concepts/layouts)** (`_layout.tsx`) - shared page chrome
(nav, sidebar, footer)
3. **Page component** - the route itself
The app wrapper wraps everything. Layouts sit inside it and wrap the page.
## Accessing request data
The app wrapper receives the same props as page components - `url`, `state`,
`params`, and more. This is useful for conditional logic:
```tsx routes/_app.tsx
import { define } from "../utils.ts";
export default define.page(({ Component, url, state }) => {
return (
My App
);
});
```
## Skipping the app wrapper
Some routes may need to bypass the app wrapper entirely - for example, API
routes that return JSON, or pages that need a completely different HTML
structure. Use `skipAppWrapper` in the route config:
```tsx routes/embed.tsx
import { type RouteConfig } from "fresh";
import { define } from "../utils.ts";
export const config: RouteConfig = {
skipAppWrapper: true,
};
export default define.page(() => {
return (
Embed
Embeddable widget
);
});
```
When using programmatic layouts, pass `skipAppWrapper` as an option:
```ts main.ts
app.layout("/embed", EmbedLayout, { skipAppWrapper: true });
```