Scripts2026年4月8日·1 分钟阅读

Sandpack — AI-Powered Live Code Editor Component

Embed live code editors in web apps with instant preview. Sandpack by CodeSandbox powers interactive coding experiences for AI chatbots, docs, and educational platforms.

SC
Script Depot · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

npm install @codesandbox/sandpack-react

一行组件嵌入可编辑代码 + 即时预览。

什么是 Sandpack?

CodeSandbox 的开源实时代码编辑器组件。浏览器内编辑代码并即时预览,Claude.ai artifacts 和 Vercel v0 均使用。

一句话总结:实时代码编辑器组件,浏览器内编辑+即时预览,Claude.ai artifacts 和 Vercel v0 使用,支持 React/Vue/Angular,零服务器,5k+ stars。

适合人群:AI 聊天和平台需要代码实时预览的开发者。

核心功能

1. 多模板 — React/Vue/Angular/Node.js

2. 自定义文件 — 任意文件结构

3. npm 依赖 — 浏览器内安装使用

4. AI 集成 — 渲染 AI 生成的代码

常见问题

Q: 需要服务器? A: 不需要,浏览器内打包运行。

Q: Claude.ai 怎么用的? A: Claude artifacts 用 Sandpack 渲染生成的 React 代码。

来源与致谢

codesandbox/sandpack — 5k+ stars, Apache 2.0

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产