Creating Custom Component with Nuxt3 and Builder.io

Hi, I’ve been trying to register custom component on my account on a single page model. I’ve been followong this tutorial (Registering Custom Components - Builder.io) and also i have copied this github ( builder/examples/vue/nuxt-3-catchall/pages/[...app].vue at main · BuilderIO/builder · GitHub ) and created the same files and components as the nuxt3-catchall repository. But it does not doing anything, and i cannot see my custom component in the related builder editor page.

I’m with last @builder.io/sdk-vue (2.0.20).

This is what I have done :

Create a component in @/components/HelloWorld.vue

<template>
    <div class="hello-world">
      <div class="text">Hello {{ text }}!</div>
      <slot></slot>
    </div>
  </template>
  
  <script>
  export default {
    props: {
      text: {
        type: String,
        default: 'world',
      },
    },
  };
  </script>
  
  <style scoped>
  .hello-world {
    display: flex;
    flex-direction: column;
  }
  .text {
    padding: 50px;
  }
  </style>

Then in @pages/[..page].vue (with of course the right API KEY) :

<template>
  <div id="home">
    <div>Hello world from your Vue project. Below is Builder Content:</div>

    <div v-if="content || isPreviewing()">
      <div>
        page title:
        {{ content?.data?.title || 'Unpublished' }}
      </div>
      <Content
        model="test"
        :content="content"
        :api-key="BUILDER_PUBLIC_API_KEY"
        :customComponents="REGISTERED_COMPONENTS"
      />
    </div>
    <div v-else>Content not Found</div>
  </div>
</template>

<script setup>
import { Content, fetchOneEntry, isPreviewing } from '@builder.io/sdk-vue';

import HelloWorldComponent from '../components/HelloWorld.vue';

// Register your Builder components
const REGISTERED_COMPONENTS = [
  {
    component: HelloWorldComponent,
    name: 'MyFunComponent',
    canHaveChildren: true,
    inputs: [
      {
        name: 'text',
        type: 'string',
        defaultValue: 'World',
      },
    ],
  },
];

// TODO: enter your public API key
const BUILDER_PUBLIC_API_KEY = 'XXXX'; // ggignore

const route = useRoute();

// fetch builder content data
const { data: content } = await useAsyncData('builderData', () =>
  fetchOneEntry({
    model: 'test',
    apiKey: BUILDER_PUBLIC_API_KEY,
    userAttributes: {
      urlPath: route.path,
    },
  })
);
</script>

But in my model nothing happens :

Even if my page is in my localhost :

Capture d’écran 2024-10-16 à 15.47.27

What do i miss ?

Many thanks

Hi, my name is Veronika and I am a Customer Engineer here at Builder.io.

You seem to be following the proper documentation in order to integrate Builder, and looking at the proper Github repository for reference. I have the same GitHub repository open and am reproducing and troubleshooting the issue.

Here is a helpful doc on the particular Vue/ Nuxt Framework you are using just to make sure it’s integrated seamlessly into your application.

It looks like you’ve registered the component correctly in your code and your HelloWorld.vue component looks good.

The only difference I am seeing in your code from the general repository code is the model name in your @pages/[..page].vue file.

const { data: content } = await useAsyncData('builderData', () =>
  fetchOneEntry({
    model: 'test',
    apiKey: BUILDER_PUBLIC_API_KEY,
    userAttributes: {
      urlPath: route.path,
    },
  })
);
</script>

Can you ensure that your model configuration is correct and matches the model you have in Builder? Ensure that you are using the test model. The repository code uses a page model, which might be the issue at hand here.

Make sure that if you have a page model called test if that is what you are intending to use.

Also, are you getting any errors in the console? If you are, could you screenshot them and let me have a look?

You are also welcome to share your API key so I can go into your ORG and have a look!

Let me know if you have any further questions,

Thank you.

Thanks for your response.

Here my model :

I do have a page model test and in my code i use test as model as you can see in my previous post.

Do i post my API KEY here ?

Also no error in my console

I’m working on localhost

Hi!

Thank you for getting back to us.

You can send through your API key here and I can go into your ORG and have a look.

Thank you,