@21st-extension/toolbar

中文文档
0.5.14发布于 2025/07/07AGPL-3.0-onlyTypeScriptESM + CJS近 30 天下载 1.3万

21st.dev toolbar SDK for AI Agent interaction.

原始使用文档
文档目录13 节
  1. About the project
  2. ✨ Features
  3. 🔧 Local Development
  4. 📖 Quickstart
  5. 1. 🧩 Install the code editor extension (Cursor, Windsurf, V…
  6. 2. 👨🏽‍💻 Install and inject the toolbar
  7. Framework-specific integration examples
  8. 🤖 Agent support
  9. 🛣️ Roadmap
  10. 📜 License
  11. 🤝 Contributing
  12. 💬 Community & Support
  13. 📬 Contact Us

21st.dev logo 21st.dev Toolbar

Visual vibe coding. Right in your codebase.

VS Code Marketplace Version GitHub Repo stars Join us on Discord

stagewise demo

About the project

stagewise is a browser toolbar that connects your frontend UI to your code ai agents in your code editor.

  • 🧠 Select any element(s) in your web app
  • 💬 Leave a comment on it
  • 💡 Let your AI-Agent do the magic

Perfect for devs tired of pasting folder paths into prompts. stagewise gives your AI real-time, browser-powered context.

✨ Features

The stagewise Toolbar makes it incredibly easy to edit your frontend code with AI agents:

  • ⚡ Works out of the box
  • 🧩 Customise and extend functionality with Plugins
  • 🧠 Sends DOM elements & more metadata to your AI agent
  • 🧪 Comes with examples for React, Vue, Svelte and more
  • 🔍 Search and integrate UI components from 21st.dev library
  • 🚨 Runtime error detection with intelligent assistance
  • 🪄 AI-powered component generation with Magic Chat

🔧 Local Development

For local development with your own API server, edit the TWENTY_FIRST_URL constant in toolbar/core/src/constants.ts:

// For local development
export const TWENTY_FIRST_URL = 'http://localhost:3000';

// For production (default)
export const TWENTY_FIRST_URL = 'https://21st.dev';

📖 Quickstart

1. 🧩 Install the code editor extension (Cursor, Windsurf, VS Code, Trae IDE, Kilo Code)

Install the extension here: https://marketplace.visualstudio.com/items?itemName=stagewise.stagewise-vscode-extension

2. 👨🏽‍💻 Install and inject the toolbar

[!TIP] 🪄 Auto-Install the toolbar (AI-guided):

  1. In Cursor, Press CMD + Shift + P
  2. Enter setupToolbar
  3. Execute the command and the toolbar will init automatically 🦄

Or follow the manual way:

Install @21st-extension/toolbar:

pnpm i -D @21st-extension/toolbar

Inject the toolbar into your app dev-mode:

// 1. Import the toolbar
import { initToolbar } from '@21st-extension/toolbar';

// 2. Define your toolbar configuration
const stagewiseConfig = {
  plugins: [],
};

// 3. Initialize the toolbar when your app starts
// Framework-agnostic approach - call this when your app initializes
function setupStagewise() {
  // Only initialize once and only in development mode
  if (process.env.NODE_ENV === 'development') {
    initToolbar(stagewiseConfig);
  }
}

// Call the setup function when appropriate for your framework
setupStagewise();

⚡️ The toolbar will automatically connect to the extension!

[!IMPORTANT] 🚫 If nothing happens when a prompt is sent:

If you have multiple Cursor windows open, the toolbar may send prompts to the wrong window, making it appear as if "no prompt is being sent". To ensure reliable operation:

  • Keep only one Cursor window open when using stagewise

A fix for this is on the way!

Framework-specific integration examples

For easier integration, we provide framework-specific NPM packages that come with dedicated toolbar components (e.g., <TwentyFirstToolbar>). You can usually import these from @21st-extension/toolbar-[framework-name].

React.js

We provide the @21st-extension/toolbar-react package for React projects. Initialize the toolbar in your main entry file (e.g., src/main.tsx) by creating a separate React root for it. This ensures it doesn't interfere with your main application tree.

// src/main.tsx
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App.tsx';
import { TwentyFirstToolbar } from '@21st-extension/toolbar-react';
import './index.css';

// Render the main app
createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <App />
  </StrictMode>,
);

// Initialize toolbar separately
const toolbarConfig = {
  plugins: [], // Add your custom plugins here
};

document.addEventListener('DOMContentLoaded', () => {
  const toolbarRoot = document.createElement('div');
  toolbarRoot.id = 'stagewise-toolbar-root'; // Ensure a unique ID
  document.body.appendChild(toolbarRoot);

  createRoot(toolbarRoot).render(
    <StrictMode>
      <TwentyFirstToolbar config={toolbarConfig} />
    </StrictMode>
  );
});
Next.js

Use the @21st-extension/toolbar-next package for Next.js applications. Include the <TwentyFirstToolbar> component in your root layout file (src/app/layout.tsx).

// src/app/layout.tsx
import { TwentyFirstToolbar } from '@21st-extension/toolbar-next';

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en">
      <body>
        <TwentyFirstToolbar
          config={{
            plugins: [], // Add your custom plugins here
          }}
        />
        {children}
      </body>
    </html>
  );
}
Nuxt.js

For Nuxt.js projects, you can use the @21st-extension/toolbar-vue package. Place the <TwentyFirstToolbar> component in your app.vue or a relevant layout file.

// app.vue
<script setup lang="ts">
import { TwentyFirstToolbar, type ToolbarConfig } from '@21st-extension/toolbar-vue';

const config: ToolbarConfig = {
  plugins: [], // Add your custom plugins here
};
</script>

<template>
  <div>
    <NuxtRouteAnnouncer />
    <ClientOnly>
      <TwentyFirstToolbar :config="config" />
    </ClientOnly>
    <NuxtWelcome />
  </div>
</template>
Vue.js

Use the @21st-extension/toolbar-vue package for Vue.js projects. Add the <TwentyFirstToolbar> component to your main App component (e.g., App.vue).

// src/App.vue
<script setup lang="ts">
import { TwentyFirstToolbar, type ToolbarConfig } from '@21st-extension/toolbar-vue';

const config: ToolbarConfig = {
  plugins: [], // Add your custom plugins here
};
</script>

<template>
  <TwentyFirstToolbar :config="config" />
  <div>
    <!-- Your app content -->
  </div>
</template>
SvelteKit

For SvelteKit, you can integrate the toolbar using @21st-extension/toolbar and Svelte's lifecycle functions, or look for a dedicated @21st-extension/toolbar-svelte package if available. Create a component that conditionally renders/initializes the toolbar on the client side (e.g., src/lib/components/TwentyFirstToolbarLoader.svelte or directly in src/routes/+layout.svelte).

Using onMount in +layout.svelte (with @21st-extension/toolbar):

<!-- src/routes/+layout.svelte -->
<script lang="ts">
  import { onMount } from 'svelte';
  import { browser } from '$app/environment';
  import { initToolbar, type ToolbarConfig } from '@21st-extension/toolbar'; // Adjust path if needed

  onMount(() => {
    if (browser) {
      const stagewiseConfig: ToolbarConfig = {
        plugins: [
          // Add your Svelte-specific plugins or configurations here
        ],
      };
      initToolbar(stagewiseConfig);
    }
  });
</script>

<slot />

Using a loader component (example from repository): The example repository uses a ToolbarLoader.svelte which wraps ToolbarWrapper.svelte. ToolbarWrapper.svelte would then call initToolbar from @21st-extension/toolbar.

<!-- examples/svelte-kit-example/src/lib/components/stagewise/ToolbarLoader.svelte -->
<script lang="ts">
import type { ToolbarConfig } from '@21st-extension/toolbar';
// ToolbarWrapper.svelte is a custom component that would call initToolbar
import ToolbarWrapper from './ToolbarWrapper.svelte'; 
import { browser } from '$app/environment';

const stagewiseConfig: ToolbarConfig = {
  plugins: [
    // ... your svelte plugin config
  ],
};
</script>

{#if browser}
  <ToolbarWrapper config={stagewiseConfig} />
{/if}

You would then use TwentyFirstToolbarLoader in your src/routes/+layout.svelte.

🤖 Agent support

AgentSupported
Cursor✅
GitHub Copilot✅
Windsurf✅
Cline✅
Roo Code✅
Trae IDE✅
Kilo Code✅
Claude Code✅ (via Copy Prompt)
Gemini CLI✅ (via Copy Prompt)
Any AI Agent✅ (via Copy Prompt)

🛣️ Roadmap

Check out our project roadmap for upcoming features, bug fixes, and progress.

📜 License

stagewise is developed by tiq UG (haftungsbeschränkt) and offerend under the AGPLv3 license.

For more information on the license model, visit the FAQ about the GNU Licenses.

For use cases that fall outside the scope permitted by the AGPLv3 license, feel free to 📬 Contact Us.

🤝 Contributing

We're just getting started and love contributions! Check out our CONTRIBUTING.md guide to get involved. For bugs and fresh ideas, please Open an issue!

💬 Community & Support

📬 Contact Us

Got questions or want to license stagewise for commercial or enterprise use?

📧 [email protected]

版本与发布记录

@21st-extension/toolbar 共发布 14 个版本,首次发布于 2025/06/26;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.5.14latest2025/07/071.3 年前
0.5.132025/07/071.3 年前
0.5.122025/07/061.3 年前
0.5.112025/07/041.3 年前
0.5.102025/07/031.3 年前
0.5.72025/07/021.3 年前

关于 @21st-extension/toolbar 的常见问题

@21st-extension/toolbar 是什么?

21st.dev toolbar SDK for AI Agent interaction.

如何安装 @21st-extension/toolbar?

在项目目录运行 npm install @21st-extension/toolbar,或使用 pnpm add / yarn add / bun add。

@21st-extension/toolbar 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@21st-extension/toolbar 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@21st-extension/toolbar 可以商用吗?

@21st-extension/toolbar 使用 AGPL-3.0-only 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@21st-extension/toolbar 的下载量有多少?

根据 npm 官方下载统计,@21st-extension/toolbar 在 2026/10/05 – 2026/11/03 这 30 天内被下载 12,803 次,日均约 427 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@21st-extension/toolbar 还在维护吗?

最新版本 0.5.14 发布于 2025/07/07(1.3 年前);至今共发布 14 个版本,其中过去 12 个月发布了 0 个;首次发布于 2025/06/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。