Hey! I am trying to dynamically switch between 2 components depending on a cookie that is set on client-side so my landingpage also works without javascript. The NoJsSwitch-component renders the correct slot, but the DynamicHero-component is not interactive on the client. It looks like this:
index.astro
---
import Layout from "@layouts/Layout.astro";
import DynamicHero from "@components/DynamicHero.vue";
import StaticHero from "@components/StaticHero.astro";
import NoJsSwitch from "@components/NoJsSwitch.astro";
---
<Layout>
<NoJsSwitch server:defer>
<DynamicHero client:load slot="js" />
<StaticHero slot="no-js" />
</NoJsSwitch>
</Layout>
NoJsSwitch.astro
---
import { USES_JS_KEY } from "@scripts/client-cookie";
const usesJs = Astro.cookies.get(USES_JS_KEY)?.value ?? false;
---
{usesJs ? <slot name="js" /> : <slot name="no-js" />}
DynamicHero.vue
<script setup lang="ts">
import { onMounted } from "vue";
// some stuff
onMounted(() => {
// some more stuff...
});
</script>
<template>
<!-- more stuff -->
</template>