ソース情報
- リポジトリ
- vercel/v0-sdk
- ソースの最終更新活動
- 2026年7月30日 23:14
- 検出された SKILL.md の言語
- 英語
- スター
- 514
- フォーク
- 116
インストール方法
デフォルトでは、最初にソースを確認する Prompt が選択されています。直接コマンドに切り替えるか、ローカルコピーをダウンロードすることもできます。
ソースファイルを確認
インストールを決める前に、SKILL.md と SkillsMP に表示されている付属ファイルをお読みください。
メニュー
デフォルトでは、最初にソースを確認する Prompt が選択されています。直接コマンドに切り替えるか、ローカルコピーをダウンロードすることもできます。
インストールを決める前に、SKILL.md と SkillsMP に表示されている付属ファイルをお読みください。
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
直接コマンドでは確認用 Prompt が省略されます。実行前にソースを確認してください。
npx skills add https://github.com/vercel/v0-sdk --skill v0コマンドは1行のまま表示されます。コピー前に横へスクロールして全体を確認してください。
ローカルで確認しますか?SkillsMP が現在取得できるファイルをダウンロードできます。
SOC 職業分類に基づく
SKILL.md を表示中
| name | v0 |
| description | Build and modify applications that use the v0 API, TypeScript SDK, and React package. |
Use this guidance when building or modifying applications that use the v0 TypeScript SDK.
v0. For React clients, install @v0-sdk/react; add ai and @ai-sdk/react for AI SDK chat, or swr for the generated API hooks.import { v0 } from 'v0' for simple server-side usage.createV0Client when the application needs custom authentication, a custom base URL, or custom fetch options.V0_API_KEY on the server. Never expose it to client components or browser code.Use v0.chats.create({ message }) when the caller can wait for completion. Non-streaming SDK methods return a result containing data or error:
const response = await v0.chats.create({ message })
if (response.error) throw new Error(response.error.message)
const chat = response.data.chat
Store chat.id so later requests can continue the same workspace. Chat metadata can be used for application grouping, customer IDs, or internal routing.
Use v0.chats.createStream({ message }) for interactive interfaces that show progress.
v0.messages.send({ chatId, message }) to continue an existing chat synchronously.v0.messages.sendStream({ chatId, message }) to stream progress for an existing chat.parts when the UI needs to show thinking, file edits, tool calls, and final text.The SDK stream result can be returned directly from a server with result.toResponse(), or consumed with for await (const update of result.stream).
On the client, use readV0Stream(response) when consuming the v0 wire format directly. Prefer streaming for chat-style interfaces so the UI can update while v0 thinks, edits files, and reports usage.
Keep the v0 client on the server. React components should call authenticated, application-owned proxy routes rather than the v0 API directly. Validate the request in each route, call the matching v0 SDK method, and return its data or stream. A streaming route can return result.toResponse() directly.
For chat interfaces, prefer AI SDK's useChat with V0Transport:
import { useChat } from '@ai-sdk/react'
import {
shouldResumeV0Chat,
toV0UIMessages,
V0Transport,
type MessagesListResponse,
type V0UIMessage,
} from '@v0-sdk/react'
import { useMemo } from 'react'
export function Chat({
chatId,
history,
}: {
chatId?: string
history: MessagesListResponse['messages']
}) {
const transport = useMemo(
() =>
new V0Transport({
chatId,
messages: history,
urls: {
create: '/api/v0/chats/stream',
send: (id) => `/api/v0/chats/${id}/messages/stream`,
resume: (id) => `/api/v0/chats/${id}/resume`,
},
}),
[chatId, history],
)
const chat = useChat<V0UIMessage>({
id: chatId,
messages: toV0UIMessages(history),
resume: shouldResumeV0Chat(history),
transport,
})
return <button onClick={() => chat.sendMessage({ text: 'Build a dashboard' })}>Send
}
toV0UIMessages converts persisted, newest-first v0 history to chronological AI SDK messages while preserving text, reasoning, files, tool activity, metadata, and resumable state.chat.messages by iterating over each message's parts; send text with chat.sendMessage({ text }).V0Transport's onChatCreated callback to store the returned chat ID or navigate to its page.useStopMessage for the active assistant message, then call AI SDK's chat.stop() locally.For API reads and mutations outside the live chat stream, import the generated SWR hooks from @v0-sdk/react/swr:
import { useChat, useMessages, useUpdateChat } from '@v0-sdk/react/swr'
const chat = useChat(`/api/v0/chats/${chatId}`)
const messages = useMessages(`/api/v0/chats/${chatId}/messages`, { limit: 50 })
const update = useUpdateChat(`/api/v0/chats/${chatId}`)
Query hooks expose SWR state such as data, error, isLoading, and mutate. Mutation hooks expose trigger and isMutating. Pass null as a query URL when required data is not ready. Successful mutations revalidate related mounted queries by default; pass revalidate: false in mutation configuration to opt out.
Import browser-safe v0 types, V0Transport, message conversion helpers, and getPendingV0Task from @v0-sdk/react. Import generated query and mutation hooks only from @v0-sdk/react/swr.
Use v0.chats.getPreview({ chatId }) after a chat exists. As with other non-streaming methods, check response.error and read the preview from response.data.
Generated previews are untrusted code. Embed them through a dedicated preview proxy deployed on a different registrable domain from the host application, not on the host origin or a same-site subdomain. Keep that proxy free of host-app sessions and unrelated application routes.
Use the SDK's fetchPreview helper in the dedicated proxy. It obtains and
refreshes short-lived preview credentials, forwards preview requests, and
returns the loading fallback while a preview is stale or starting. Never send
V0_API_KEY to the preview URL or browser.
The iframe needs sandbox="allow-scripts allow-same-origin ..." for generated
React apps to hydrate and run normally. The separate proxy origin provides the
security boundary; do not remove allow-same-origin as a substitute for origin
isolation.
Use the documentation for endpoint details.