<NuxtClientFallback>
Nuxt provides the <NuxtClientFallback> component to render its content on the client if any of its children trigger an error in SSR.
<NuxtClientFallback> is deprecated. <NuxtErrorBoundary> now catches server-side errors too, and its retry-on-client prop provides the same "try again on the client" behaviour, with the error available in the #error slot.
<NuxtClientFallback> | <NuxtErrorBoundary> |
|---|---|
<NuxtClientFallback> | <NuxtErrorBoundary retry-on-client> |
#fallback / #placeholder slot | #error slot |
fallback, fallback-tag, placeholder, placeholder-tag props | markup in the #error slot |
keep-fallback | omit retry-on-client |
@ssr-error | @error |
@ssr-error is only emitted on the server, whereas @error is also emitted for errors thrown in the browser. Guard handlers with import.meta.server if they should only run on the server.
experimental.clientFallback option in your nuxt.config.<template>
<div>
<Sidebar />
<!-- this component will be rendered on client-side -->
<NuxtClientFallback fallback-tag="span">
<Comments />
<BrokeInSSR />
</NuxtClientFallback>
</div>
</template>Events
@ssr-error: Event emitted when a child triggers an error in SSR. Note that this will only be triggered on the server.<template> <NuxtClientFallback @ssr-error="logSomeError"> <!-- ... --> </NuxtClientFallback> </template>
Props
placeholderTag|fallbackTag: Specify a fallback tag to be rendered if the slot fails to render on the server.- type:
string - default:
div
- type:
placeholder|fallback: Specify fallback content to be rendered if the slot fails to render.- type:
string
- type:
keepFallback: Keep the fallback content if it failed to render server-side.- type:
boolean - default:
false
- type:
placeholder and fallback props render content as raw HTML. Do not pass untrusted user input to these props as it may lead to XSS vulnerabilities. Use the #fallback or #placeholder slots instead for dynamic content that needs proper escaping.<template>
<!-- render <span>Hello world</span> server-side if the default slot fails to render -->
<NuxtClientFallback
fallback-tag="span"
fallback="Hello world"
>
<BrokeInSSR />
</NuxtClientFallback>
</template>Slots
#fallback: specify content to be displayed server-side if the slot fails to render.
<template>
<NuxtClientFallback>
<!-- ... -->
<template #fallback>
<!-- this will be rendered on server side if the default slot fails to render in ssr -->
<p>Hello world</p>
</template>
</NuxtClientFallback>
</template>