Skill

Wire beta React renderer into React 18+ and Next.js apps

Wires Markstream's beta streaming markdown renderer into React 18+ or Next.js with correct client/server entrypoints and safe defaults.

Works with reactnextjs

81
Spark score
out of 100
Updated 3 days ago
Version 15.3.0

Add to Favorites

Why it matters

Integrate the Markstream beta React renderer into React 18+ or Next.js applications with proper streaming, component overrides, and client/server boundary management for markdown rendering in AI-powered interfaces.

Outcomes

What it gets done

01

Install and configure the beta renderer with correct peer dependencies and CSS imports

02

Set up streaming markdown with typewriter effects, fade transitions, and cursor controls for live chat

03

Configure component overrides using streamingComponents and htmlComponents registries

04

Validate client, server, and incremental rendering paths with safe HTML policies

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/ag-markstream-react | bash

Overview

Markstream React

Wires Markstream's beta streaming markdown renderer into React 18+ or Next.js, using the correct root/next/server entrypoint and safe HTML/Mermaid defaults. Use for React or Next.js apps adding Markstream streaming markdown; pair with markstream-migration when replacing an existing renderer.

What it does

This skill wires the beta React renderer into React 18+ or Next.js without crossing client/server boundaries or reaching for AST control unnecessarily. Its workflow: before changing dependencies or source files, inspect the existing package manager and project conventions, preview the intended edits, and obtain explicit user approval; confirm React 18+ and acceptance of a beta package; install only the specifically requested peers and import markstream-react/index.css; use the root entry point for client rendering, /next for Next-specific components, and /server for server rendering without client hooks; start with the content prop and smoothStreaming="auto", using nodes plus final only when another layer already owns parsing; for live chat disable fade and opt into the cursor, then on completion set final, disable pacing/cursor, and enable fade only if desired; keep browser-only peers inside a 'use client' boundary, dynamic ssr: false, or another minimal boundary; prefer streamingComponents for parser-backed tags and htmlComponents for sanitized props, using scoped registry overrides for built-in nodes; and keep htmlPolicy="safe" and Mermaid strict, validating the client, server, and incremental paths. It's meant to pair with the markstream-migration skill when the actual goal is replacing an existing renderer.

Documented limitations: the package is beta and requires React 18+, browser-only peers require client boundaries under SSR, and complex parser parity requires separate migration review. A security note: review dependencies and never opt untrusted model output into trusted HTML or loose diagram rendering.

When to use - and when NOT to

Use for React/Next setup, root/next/server entrypoints, streaming, component overrides, or migration support. Pair with markstream-migration when the actual task is renderer replacement rather than a fresh integration.

Inputs and outputs

Input is an existing React 18+ or Next.js application. Output is a working MarkdownRender integration using the correct entrypoint (root/next/server) for its rendering context, with browser-only peers scoped to client boundaries and HTML/Mermaid trust kept at safe defaults.

import MarkdownRender from 'markstream-react'
import 'markstream-react/index.css'

export function StreamingAnswer({
  content,
  isDone,
}: {
  content: string
  isDone: boolean
}) {
  return (
    <MarkdownRender
      content={content}
      final={isDone}
      fade={isDone}
      typewriter={!isDone}
      smoothStreaming={isDone ? false : 'auto'}
      htmlPolicy="safe"
    />
  )
}

Who it's for

React 18+ or Next.js developers integrating Markstream's beta streaming markdown renderer who need the right client/server entrypoint and safe HTML/Mermaid defaults.

Source README

Markstream React

Overview

Wire the beta React renderer into React 18+ or Next.js without crossing client/server boundaries or reaching for AST control unnecessarily.

When to Use

Use for React/Next setup, root/next/server entrypoints, streaming, component overrides, or migration support. Pair with markstream-migration for renderer replacement.

Workflow

Before changing dependencies or source files, inspect the existing package manager and project conventions, preview the intended edits, and obtain explicit user approval.

  1. Confirm React 18+ and acceptance of a beta package.
  2. Install only requested peers and import markstream-react/index.css.
  3. Use the root entry for client rendering, /next for Next-specific components, and /server for server rendering without client hooks.
  4. Start with content and smoothStreaming="auto"; use nodes plus final only when another layer owns parsing.
  5. For live chat disable fade and opt into the cursor. On completion set final, disable pacing/cursor, and enable fade only if desired.
  6. Keep browser-only peers inside 'use client', dynamic ssr: false, or another minimal boundary.
  7. Prefer streamingComponents for parser-backed tags and htmlComponents for sanitized props. Use scoped registry overrides for built-in nodes.
  8. Keep htmlPolicy="safe" and Mermaid strict; validate client, server, and incremental paths.

Example

import MarkdownRender from 'markstream-react'
import 'markstream-react/index.css'

export function StreamingAnswer({
  content,
  isDone,
}: {
  content: string
  isDone: boolean
}) {
  return (
    <MarkdownRender
      content={content}
      final={isDone}
      fade={isDone}
      typewriter={!isDone}
      smoothStreaming={isDone ? false : 'auto'}
      htmlPolicy="safe"
    />
  )
}

Limitations

  • The package is beta and requires React 18+.
  • Browser-only peers require client boundaries under SSR.
  • Complex parser parity requires separate migration review.

Security & Safety Notes

Review dependencies and never opt untrusted model output into trusted HTML or loose diagram rendering.

Discussion

Questions & comments ยท 0

Sign In Sign in to leave a comment.