Embedding
Integrating the Clepit editor or renderer into any application is straightforward: a DOM container is the single point of control.
Mounting the editor
Give a container element an id, call `Editor.create({ containerId, ... })`, keep the returned `EditorAPI`, and call `Editor.destroy(containerId)` on teardown.
import { Editor } from '@clepit/core';
import type { EditorAPI } from '@clepit/core';
// 1. Give your container a stable id
// <div id="my-editor"></div>
// 2. Create the editor and hold the returned API
const editor: EditorAPI = Editor.create({
containerId: 'my-editor',
minHeight: 400,
placeholder: 'Start writing...',
theme: 'auto',
onChange: data => console.log(data),
onReady: () => console.log('Editor ready'),
});
// 3. Extract content any time
const data = editor.data.extract();
// 4. Destroy on teardown (e.g. component unmount)
Editor.destroy('my-editor');Rendering output read-only
Call `Renderer.render({ containerId, data })`. The example below shows the real React pattern from the `DocsRenderer` component: `useId` generates a unique container id and `useEffect` triggers the render.
import { Renderer } from '@clepit/core';
import type { EditorData } from '@clepit/core';
import { useEffect, useId } from 'react';
type Props = { content: EditorData };
const ReadOnlyView = ({ content }: Props) => {
// useId produces a stable, unique id per component instance
const containerId = useId().replace(/[^a-z0-9]/gi, '');
useEffect(() => {
Renderer.render({
containerId,
data: content,
margins: { bottom: 0, top: 0 },
});
}, [containerId, content]);
return <div id={containerId} />;
};Client-only rendering / SSR
Both Editor and Renderer operate on the DOM, so they run in the browser only: use effects (`useEffect`) or the `'use client'` directive. They do not run during SSR.
Framework-agnostic
The core @clepit/core package is plain TypeScript, no React dependency. Whether you use React, Vue, Svelte, Angular, or vanilla TS/JS, all host the same API.