Skip to content

Nuxt

Nuxt renders Vue, and Vue passes unknown elements straight through, so the Vue component works in Nuxt with no changes and no wrapper package.

components/ContactForm.vue
<script setup lang="ts">
const { form } = defineProps<{ form: string }>();
</script>
<template>
<formbuilder-form :form="form" />
</template>
pages/contact.vue
<template>
<ClientOnly>
<ContactForm :form="config.public.formId" />
</ClientOnly>
</template>
<script setup lang="ts">
const config = useRuntimeConfig();
useHead({
script: [
{
type: 'module',
src: 'https://forms.justinjongstra.nl/formbuilder/asset/element.js',
},
],
link: [{ rel: 'preconnect', href: 'https://forms.justinjongstra.nl' }],
});
</script>

Vue logs a warning for tags it does not recognise. Tell it this one is a custom element and the warning goes away:

nuxt.config.ts
export default defineNuxtConfig({
vue: {
compilerOptions: {
isCustomElement: (tag) => tag === 'formbuilder-form',
},
},
});

Cosmetic only: the form renders either way.