---
title: "NUXT_E2007"
description: "setPageLayout called on server within component."
canonical_url: "https://nuxt.com/docs/4.x/errors/e2007"
---
# E2007

`setPageLayout()` was called from a component's `setup()` during SSR. On the server the layout must be decided before the component renders, so changing it here produces incorrect SSR output.

## Resolution

Set the layout from route middleware, or statically with `definePageMeta({ layout: '...' })`.

<read-more to="https://nuxt.com/docs/4.x/api/utils/set-page-layout">



</read-more>


## Sitemap

See the full [sitemap](https://nuxt.com/sitemap.md) for all pages.
