NuxtIsland

`NuxtIsland` is the base component of Server Components

Preview

Client Component

Server Component

This component is not included in the bundle

If count is changed, code is changed.

const a = 0

Client Component

Client Components can be put in the Server Components slot.

Code

    components
    • islands
    pages
      examples
<script setup lang="ts">
definePageMeta({
  layout: 'example',
});

const count = ref(0);
</script>
<template>
  <Boundary label="Client Component">
    <button class="mt-2 rounded-md bg-gray-800 px-2 py-1" @click="count++">
      increment
    </button>
    <NuxtIsland name="IslandCodeExample" :props="{ count }">
      <Boundary label="Client Component" class="mt-6">
        <p>Client Components can be put in the Server Components slot.</p>
        <button class="mt-2 rounded-md bg-gray-800 px-2 py-1" @click="count--">
          decrement
        </button>
      </Boundary>
    </NuxtIsland>
  </Boundary>
</template>