Once your end-user has published their documents that they made with your Embed editor - you will want a way to preview that document live without the editor UI.

Each user’s document has multiple versioned content but each document only has exactly one published content.

Whenever your users edit a document, this will create a new versioned content. Then, when they decide to publish - the latest content will be used as the “published” content.

Retrieving document content

You can retrieve a user document’s content(s) via the @mirinhq/admin sdk:

import { Client } from '@mirinhq/admin';

const client = new Client(
  apiKey: '...',
);


const getDocumentContent = (documentId: string) => {
  return client.getDocumentContents(documentId); // [{ id: '...', date: '...' }]
}

const getPublishedDocumentContent = (documentId: string) => {
  return client.getPublishedContent(documentId); // { id: '...', date: '...' } | null
}

Rendering the content in preview

Finally, to render the specified content without the editor UI - all you need to do is to render the <Preview /> component with the relevant contentId.

import { Preview } from '@mirinhq/embed';

export default function YourLivePage() {
  return (
    <Preview documentId="..." />
  )
}