@vercube/nuxt-lazy-hydration
v1.3.0
Published
Optimize Vue 3 SSR with lazy hydration, delaying HTML hydration until it's needed for better performance
Downloads
244
Maintainers
Readme
@vercube/nuxt-lazy-hydration
Lazy Hydration of Server-Side Rendered for Nuxt 3
👉 Demo with Nuxt on StackBlitz
Installation
# or npm / yarn
$ pnpm add @vercube/nuxt-lazy-hydration
Add to modules
in nuxt.config.ts
:
import { defineNuxtConfig } from 'nuxt/config';
export default defineNuxtConfig({
modules: ['@vercube/nuxt-lazy-hydration'],
});
Usage
To use NuxtLazyHydration
just wrap your component with wrapper.
<template>
<NuxtLazyHydration whenVisible>
<p>Hydrated when component will be visible on screen<p>
</NuxtLazyHydration>
</template>
You can also use it with composable
<template>
<NeverHydratedComponent/>
</template>
<script lang="ts" setup>
const NeverHydratedComponent = useLazyHydration(
() => import('./SomeComponent.vue'),
{ ssrOnly: true },
);
</script>
Props
You can find all possible props
here