npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@v0-sdk/react

v0.4.1

Published

Headless React components for rendering v0 Platform API content

Readme

@v0-sdk/react

⚠️ Developer Preview: This SDK is currently in beta and is subject to change. Use in production at your own risk.

Headless React components and hooks for rendering content from the v0 Platform API.

Features

  • Headless by design - Works with React Native, TUIs, and any React renderer
  • Flexible rendering - Use provided JSX components or build your own with headless hooks
  • Customizable - Override any component or styling
  • Zero DOM dependencies - No react-dom required
  • Streaming support - Real-time message streaming with useStreamingMessage
  • Backward compatible - Drop-in replacement for existing implementations

Installation

npm install @v0-sdk/react
# or
yarn add @v0-sdk/react
# or
pnpm add @v0-sdk/react

Usage

Basic JSX Components (Web/React DOM)

import { Message, StreamingMessage } from '@v0-sdk/react'

function ChatMessage({ content }) {
  return (
    <Message
      content={content}
      messageId="msg-1"
      role="assistant"
      className="my-message"
    />
  )
}

function StreamingChat({ stream }) {
  return (
    <StreamingMessage
      stream={stream}
      messageId="streaming-msg"
      role="assistant"
      onComplete={(content) => console.log('Complete:', content)}
    />
  )
}

Headless Hooks (React Native/Ink/TUI)

import { useMessage, useStreamingMessageData } from '@v0-sdk/react'
import { Text, View } from 'react-native' // or any other renderer

function HeadlessMessage({ content }) {
  const messageData = useMessage({
    content,
    messageId: 'msg-1',
    role: 'assistant',
  })

  return (
    <View>
      {messageData.elements.map((element) => (
        <Text key={element.key}>
          {element.type === 'text' ? element.data : JSON.stringify(element)}
        </Text>
      ))}
    </View>
  )
}

function HeadlessStreamingMessage({ stream }) {
  const streamingData = useStreamingMessageData({
    stream,
    messageId: 'streaming-msg',
    role: 'assistant',
  })

  if (streamingData.error) {
    return <Text style={{ color: 'red' }}>Error: {streamingData.error}</Text>
  }

  if (streamingData.isStreaming && !streamingData.messageData) {
    return <Text>Loading...</Text>
  }

  return (
    <View>
      {streamingData.messageData?.elements.map((element) => (
        <Text key={element.key}>
          {element.type === 'text' ? element.data : JSON.stringify(element)}
        </Text>
      ))}
    </View>
  )
}

Ink CLI Example

import { useMessage } from '@v0-sdk/react'
import { Text, Box } from 'ink'

function CliMessage({ content }) {
  const messageData = useMessage({
    content,
    messageId: 'cli-msg',
    role: 'assistant',
  })

  return (
    <Box flexDirection="column">
      {messageData.elements.map((element) => (
        <Text key={element.key}>
          {element.type === 'text' ? element.data : `[${element.type}]`}
        </Text>
      ))}
    </Box>
  )
}

Available Hooks

Core Hooks

  • useMessage(props) - Process message content into headless data structure
  • useStreamingMessageData(props) - Handle streaming messages with real-time updates
  • useStreamingMessage(stream, options) - Low-level streaming hook

Component Hooks

  • useIcon(props) - Icon data and fallbacks
  • useCodeBlock(props) - Code block processing
  • useMath(props) - Math content processing
  • useThinkingSection(props) - Thinking section state management
  • useTaskSection(props) - Task section state and processing
  • useCodeProject(props) - Code project structure
  • useContentPart(part) - Content part analysis and processing

Available Components

All components are optional JSX renderers that work with DOM environments. For headless usage, use the corresponding hooks instead.

  • Message - Main message renderer
  • StreamingMessage - Streaming message with loading states
  • Icon - Generic icon component with fallbacks
  • CodeBlock - Code syntax highlighting
  • MathPart - Math content rendering
  • ThinkingSection - Collapsible thinking sections
  • TaskSection - Collapsible task sections
  • CodeProjectPart - Code project file browser
  • ContentPartRenderer - Handles different content part types

Supported Task Types

The package automatically handles all v0 Platform API task types:

Explicitly Supported Tasks

  • task-thinking-v1 - AI reasoning and thought processes
  • task-search-web-v1 - Web search operations with results
  • task-search-repo-v1 - Repository/codebase search functionality
  • task-diagnostics-v1 - Code analysis and issue detection
  • task-read-file-v1 - File reading operations
  • task-coding-v1 - Code generation and editing tasks
  • task-generate-design-inspiration-v1 - Design inspiration generation
  • task-start-v1 - Task initialization (usually hidden)

Future-Proof Support

Any new task type following the task-*-v1 pattern will be automatically supported with:

  • Auto-generated readable titles
  • Appropriate icon selection
  • Proper task section rendering
  • Graceful fallback handling

Customization

Custom Components

import { Message } from '@v0-sdk/react'

function CustomMessage({ content }) {
  return (
    <Message
      content={content}
      components={{
        // Override specific HTML elements
        p: ({ children }) => <MyParagraph>{children}</MyParagraph>,
        code: ({ children }) => <MyCode>{children}</MyCode>,

        // Override v0-specific components
        CodeBlock: ({ language, code }) => (
          <MyCodeHighlighter lang={language}>{code}</MyCodeHighlighter>
        ),
        Icon: ({ name }) => <MyIcon icon={name} />,
      }}
    />
  )
}

Headless Custom Rendering

import { useMessage } from '@v0-sdk/react'

function CustomHeadlessMessage({ content }) {
  const messageData = useMessage({ content })

  const renderElement = (element) => {
    switch (element.type) {
      case 'text':
        return <MyText>{element.data}</MyText>
      case 'code-project':
        return <MyCodeProject {...element.data} />
      case 'html':
        return <MyHtmlElement {...element.data} />
      default:
        return null
    }
  }

  return <MyContainer>{messageData.elements.map(renderElement)}</MyContainer>
}

TypeScript Support

Full TypeScript support with exported types:

import type {
  MessageData,
  MessageElement,
  StreamingMessageData,
  IconData,
  CodeBlockData,
  // ... and many more
} from '@v0-sdk/react'

Migration from Previous Versions

This version is backward compatible. Existing code will continue to work unchanged. To adopt headless patterns:

  1. Keep existing JSX components for web/DOM environments
  2. Use headless hooks for React Native, Ink, or custom renderers
  3. Gradually migrate components as needed

React Native Example

import { useMessage, useIcon } from '@v0-sdk/react'
import { View, Text, ScrollView } from 'react-native'

function RNMessage({ content }) {
  const messageData = useMessage({ content })

  const renderElement = (element) => {
    if (element.type === 'text') {
      return <Text key={element.key}>{element.data}</Text>
    }

    if (element.type === 'html' && element.data.tagName === 'p') {
      return (
        <Text key={element.key} style={{ marginVertical: 8 }}>
          {element.children?.map(renderElement)}
        </Text>
      )
    }

    return <Text key={element.key}>[{element.type}]</Text>
  }

  return <ScrollView>{messageData.elements.map(renderElement)}</ScrollView>
}

function RNIcon({ name }) {
  const iconData = useIcon({ name })
  return <Text>{iconData.fallback}</Text>
}

License

Apache-2.0