Skip to main content
setPageLayout allows you to dynamically change the layout of a page. It relies on access to the Nuxt context and therefore can only be called within the Nuxt context.

Type Signature

Parameters

string
required
The name of the layout to set for the current page.
Record<string, any>
Props to pass to the layout component.

Examples

Basic Usage

Passing Props to Layouts

You can pass props to the layout by providing an object as the second argument:
The layout can then receive these props:

Notes

If you choose to set the layout dynamically on the server side, you must do so before the layout is rendered by Vue (that is, within a plugin or route middleware) to avoid a hydration mismatch.

See Also