API Reference

Complete API documentation for nstreamdown components, utilities, and types. All APIs are available for Angular, React, Solid, Svelte, and Vue.

Framework Imports

Import the Streamdown component from your framework-specific path:

// Angular
import { Streamdown } from '@nstudio/nstreamdown/angular';
// React
import { Streamdown } from '@nstudio/nstreamdown/react';
// Vue
import { Streamdown } from '@nstudio/nstreamdown/vue';
// Svelte
import { Streamdown } from '@nstudio/nstreamdown/svelte';
// Solid
import { Streamdown } from '@nstudio/nstreamdown/solid';

Streamdown Component

The Streamdown component accepts the following props (property names may vary slightly by framework):

Props / Inputs
// Angular
<Streamdown [content]="markdown" [config]="config" />
// React / Solid
<Streamdown content={markdown} config={config} />
// Vue
<Streamdown :content="markdown" :config="config" />
// Svelte
<Streamdown content={markdown} {config} />

StreamdownConfig

interface StreamdownConfig {
/**
* Rendering mode
* - 'streaming': For real-time AI streaming with incomplete token handling
* - 'static': For complete, pre-rendered markdown
* @default 'static'
*/
mode?: 'streaming' | 'static';
/**
* Show interactive controls on code blocks and tables
* @default true
*/
controls?: boolean;
/**
* Show animated caret cursor during streaming
* @default true (when mode is 'streaming')
*/
showCaret?: boolean;
/**
* Custom caret character to display
* @default '▋'
*/
caret?: string;
}

Markdown Parser
Utility

import { parseMarkdown, remend } from '@nstudio/nstreamdown';
/**
* Parse markdown string into tokens
* @param content - The markdown string to parse
* @param streaming - Whether to handle incomplete tokens
* @returns ParseResult with tokens array
*/
function parseMarkdown(
content: string,
streaming?: boolean
): ParseResult;
/**
* Fix incomplete/unterminated markdown during streaming
* Automatically closes open bold, italic, code, etc.
* @param content - The incomplete markdown string
* @returns Fixed markdown string with proper termination
*/
function remend(content: string): string;
// Example
const result = parseMarkdown('# Hello **World**', true);
console.log(result.tokens);
const fixed = remend('This is **incomple');
// Returns: 'This is **incomple**'

Utility Functions
Utility

import { copyToClipboard, openUrl } from '@nstudio/nstreamdown';
/**
* Copy text to clipboard
* @param text - The text to copy
*/
function copyToClipboard(text: string): void;
/**
* Open URL in Safari
* @param url - The URL to open
*/
function openUrl(url: string): void;
// Example
copyToClipboard('Hello, World!');
openUrl('https://nativescript.org');

Token Types

type MarkdownToken =
| HeadingToken
| ParagraphToken
| CodeBlockToken
| BlockquoteToken
| ListToken
| TableToken
| ImageToken
| HorizontalRuleToken
| MathToken;
interface HeadingToken {
type: 'heading';
level: 1 | 2 | 3 | 4 | 5 | 6;
content: InlineToken[];
}
interface CodeBlockToken {
type: 'code-block';
language: string;
code: string;
}
interface TableToken {
type: 'table';
headers: string[];
rows: string[][];
alignments: ('left' | 'center' | 'right' | null)[];
}
interface MathToken {
type: 'math';
expression: string;
block: boolean;
}
// ... and more

Inline Token Types

type InlineToken =
| TextToken
| BoldToken
| ItalicToken
| StrikethroughToken
| CodeToken
| LinkToken
| ImageToken;
interface TextToken {
type: 'text';
content: string;
}
interface BoldToken {
type: 'bold';
content: InlineToken[];
}
interface LinkToken {
type: 'link';
href: string;
content: InlineToken[];
}

Exports

Each framework has its own export path with framework-specific components:

// Framework-specific component exports
// Angular: @nstudio/nstreamdown/angular
// React: @nstudio/nstreamdown/react
// Vue: @nstudio/nstreamdown/vue
// Svelte: @nstudio/nstreamdown/svelte
// Solid: @nstudio/nstreamdown/solid
export { Streamdown } from '@nstudio/nstreamdown/<framework>';
// Shared utilities (available from any path)
export { StreamdownConfig } from '@nstudio/nstreamdown';
export { parseMarkdown, remend } from '@nstudio/nstreamdown';
export { copyToClipboard, openUrl } from '@nstudio/nstreamdown';