Like any good project, let’s start with a Hello World react component, and then understand how to make this available in Embeddable’s no-code builder.

A simple React component might look like this:

<HelloWorldComponent 
  title='Hello'
  body='World'
/>

To create such a component in React, you might write something simple like this:

import React from 'react';

type Props = {
  title: string;
  body: string;
};

export default (props: Props) => {
  return (
      <div>
        <h1>{props.title}</h1>
        <div>{props.body}</div>
      </div>
    )
}

It takes two props as input, title and body, and renders them in some basic HTML.

In Embeddable we want our users to be able to customise this component via the UI:

Screenshot 2023-12-17 at 16.00.36.png

So all we need to do is tell Embeddable how to do that:

import { defineComponent } from '@embeddable.com/react';

import Component from './index';

export const meta = {
  name: 'HelloWorldComponent', 
  label: 'Hello World',
  inputs: [
    {
      name: 'title',
			label: 'Title',
      type: 'string',
    },
    {
      name: 'body',
      label: 'Body',
      type: 'string',
    },
  ]
};

export default defineComponent(Component, meta, {
  props: (inputs) => {
    return {
      title: inputs.title,
      body: inputs.body
    };
  }
});

Let’s break this down: