@codeium/react-code-editor

中文文档
1.0.12发布于 2024/02/17ISCTypeScriptES Module近 30 天下载 1.9万

AI-powered React component

原始使用文档
文档目录11 节
  1. Features
  2. Demo
  3. Getting Started
  4. Examples
  5. How it works
  6. What is Codeium
  7. API
  8. FAQ
  9. Acknowledgements
  10. Issues
  11. License

Codeium Editor

built with Codeium

NPM

Codeium React Code Editor is a free, open-source code editor as a React component with unlimited AI autocomplete. Brought to you by the team at Codeium. Free with no account required.. All you need to do is install our NPM package, add it to your website and you're good to go!

codeium demo

Features

  • Unlimited AI autocomplete (no account required)
  • Customizable API extended from Monaco React

Demo

Check it out here!

Getting Started

Install using any of these package manager.s

# NPM
npm install @codeium/react-code-editor

# Yarn
yarn add @codeium/react-code-editor

# PNPM
pnpm install @codeium/react-code-editor

Now import the CodeiumEditor and enjoy lightning fast AI autocomplete, directly in your browser, 100% for free!

import { CodeiumEditor } from "@codeium/react-code-editor";

export const IdeWithAutocomplete = () => {
  return (
    <div>
      <p>Here's an AI-powered Python editor using Codeium.</p>
      <CodeiumEditor language="python" theme="vs-dark" />
    </div>
  );
};

Here's an advanced example that uses multi-document context to provide more intelligent autocompletion:

import { CodeiumEditor, Document, Language } from "@codeium/react-code-editor";

export const JavaScriptEditorWithContext = () => {
  const html = `<html>
  <body>
    <h1>Contact Us</h1>
    <form>
      <label>Name:</label>
      <input id="name" type="text" />
      <label>Email:</label>
      <input id="email" type="text" />
    </form>
  </body>
</html>`;

  return (
    <div>
      <p>This editor has context awareness of a neighboring HTML file and can provide better autocompletion suggestions.</p>
      <CodeiumEditor
        language="javascript"
        theme="vs-dark"
        otherDocuments={[
          new Document({
            absolutePath: "/app/index.html",
            relativePath: "index.html",
            text: html,
            editorLanguage: "html",
            language: Language.HTML,
          }),
        ]}
      />
    </div>
  );
};

Note that the otherDocuments prop has a limit of 10 documents. Within those documents, Codeium will run a reranker behind the scenes to optimize what is included in the token limit.

Examples

Here are some examples of Codeium React Editor used in production:

How it works

This project is a wrapper around Microsoft's Monaco editor which is the editor that powers VS Code with the extended capability of providing code autocompletion.

The autocompletes are provided by analyzing the editor's content and predicting and providing suggestions based on that context. To learn more about how the autocompletion works, visit Codeium's FAQ.

What is Codeium

Codeium is a free, AI-powered developer toolkit that plugs into 70+ IDEs, including: Visual Studio Code, JetBrains IDEs, Google Colab, and Vim. Codeium provides unlimited AI context-aware autocomplete, chat assistant, intelligent search, codebase indexing, and more. Codeium also offers flexible deployments within your VPC or in on-prem, airgapped environments. Learn more at codeium.com.

API

The core API of the editor is the same as that of the wrapped project. You can view the editor API here.

FAQ

How can I import the ESM version of this?

To import the ESM version of this, you can use import { CodeiumEditor } from "@codeium/react-code-editor/dist/esm";. If you're using TypeScript, your editor might warn that the types are missing. A current workaround is:

  • Create a codeiumeditor.d.ts file,
  • Add declare module '@codeium/react-code-editor/dist/esm'; to the file
  • Import the types file in the file using the CodeiumEditor component.

This is an open issue in terms of supporting both CommonJS and ESM. If you're interested in contributing and have a fix for this, pull requests are welcome.

Acknowledgements

This project would not have been possible without Suren Atoyan's Monaco React project.

Issues

Create issues in this repositories for anything related to autocompletion functionality. If you have any issues with the editor API or functionality, create an issue in the editor repository.

License

License

版本与发布记录

@codeium/react-code-editor 共发布 25 个版本,首次发布于 2024/01/28;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.12latest2024/02/172 年前
1.0.112024/02/172 年前
1.0.102024/02/142 年前
1.0.92024/02/142 年前
1.0.82024/02/142 年前
1.0.72024/02/012 年前

关于 @codeium/react-code-editor 的常见问题

@codeium/react-code-editor 是什么?

AI-powered React component

如何安装 @codeium/react-code-editor?

在项目目录运行 npm install @codeium/react-code-editor,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.2.0)、react-dom(^18.2.0)、monaco-editor(^0.45.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@codeium/react-code-editor 支持 TypeScript 吗?

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

@codeium/react-code-editor 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@codeium/react-code-editor 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=16。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@codeium/react-code-editor 可以商用吗?

@codeium/react-code-editor 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@codeium/react-code-editor 的下载量有多少?

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

@codeium/react-code-editor 还在维护吗?

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