Misar IO Docs

TypeScript SDK

Embed MisarBlog content in your application with the @misar/blog TypeScript SDK

Installation

npm install @misar/blog
# or
pnpm add @misar/blog

Embed a Profile or Post

import { embed, embedUrl } from '@misar/blog';

// Get just the embed URL
const url = embedUrl({ username: 'johndoe' });

// Embed directly into a DOM container
const { iframe, destroy } = embed(document.getElementById('blog-container')!, {
  username: 'johndoe',
  width: '100%',
  height: '600px',
  theme: 'dark',
});

// Later, remove the embed
destroy();

Embed a Specific Post

const url = embedUrl({
  username: 'johndoe',
  slug: 'my-first-post',
  theme: 'light',
});

Auth Token Refresh

For authenticated embeds (e.g. paywalled content), refresh the session token:

import { refreshToken, getToken, clearToken } from '@misar/blog';

// Refresh and store token in localStorage
const result = await refreshToken({
  token: 'current-session-token',
  baseUrl: 'https://misar.blog', // optional, defaults to production
});

// Read stored token
const token = getToken(); // returns string | null

// Clear stored token on logout
clearToken();

API Reference

embedUrl(options)

Returns a URL string for the embed iframe.

| Option | Type | Description | |--------|------|-------------| | username | string | Required. Blog author username | | slug | string? | Post slug for single-post embed | | theme | 'light' \| 'dark' \| 'auto' | Color theme (default: auto) | | width | string? | CSS width for the iframe | | height | string? | CSS height for the iframe |

embed(container, options)

Appends an iframe to container and returns { iframe, destroy }.

refreshToken(options) / getToken() / clearToken()

Manage session tokens in localStorage under key "misar_blog_token".