close
  • English
  • Quick start

    Environment preparation

    Rslib supports using Node.js, Deno, or Bun as the JavaScript runtime.

    Use one of the following installation guides to set up a runtime:

    Version requirements
    • Rslib >= 0.20 requires Node.js version 20.19+, 22.12+.
    • Rslib < 0.20 requires Node.js 18.12.0 or higher.

    Creating an Rslib project

    Use create-rslib to create a new Rslib project. Run the following command:

    npm
    yarn
    pnpm
    bun
    deno
    npm create rslib@latest

    Follow the prompts step by step. During project creation, you can choose a template, language, optional tools, and optional skills.

    All templates include Rstest by default for testing.

    After creating the project, do the following:

    • Run git init to initialize a Git repository.
    • Run npm install (or your package manager's install command) to install dependencies.
    • Run npm run dev to start watch mode and begin development.

    Templates

    When creating a project, you can choose from the following templates provided by create-rslib:

    TemplateDescription
    Node.js dual ESM/CJS packageNode.js dual ESM/CJS package
    Node.js pure ESM packageNode.js pure ESM package
    ReactReact component library
    VueVue component library
    SvelteSvelte component library

    Optional tools

    create-rslib can help you set up the following commonly used tools. Use the arrow keys to navigate and the space bar to select. Press Enter without selecting anything to skip these tools.

    ToolUse
    ESLintLinting
    RslintLinting
    PrettierFormatting
    BiomeLinting and formatting
    RspressComponent documentation, React + TypeScript template
    StorybookComponent development and preview, React or Vue templates
    React CompilerOptimizing React components, React template only

    Optional skills

    create-rslib can install optional skills for coding agents that support Skills. In interactive mode, your selections in “Optional tools” affect the available skill options. The currently available skills are:

    Use the arrow keys to navigate and the space bar to select. Press Enter without selecting anything to skip.

    ◆  Select optional skills (Use <space> to select, <enter> to continue)
    │  ◻ Rslib - best practices
    │  ◻ Rstest - best practices

    For more details about Agent Skills and other AI-related capabilities, see AI.

    Current directory

    To create a project in the current directory, set the target folder to .:

    ◆  Create Rslib Project
    
    ◇  Project name or path
    │  .
    
    ◇  "." is not empty, please choose:
    │  Continue and override files

    Non-interactive mode

    create-rslib supports a non-interactive mode via command-line options. This mode skips prompts and creates the project directly, which is useful for scripts, CI, and automation.

    For example, the following command creates a React project in the my-project directory:

    npx -y create-rslib@latest my-project --template react
    
    # Using abbreviations
    npx -y create-rslib@latest my-project -t react
    
    # Specify multiple tools
    npx -y create-rslib@latest my-project -t react --tools storybook,biome
    
    # Install an optional skill for coding agents
    npx -y create-rslib@latest my-project -t react --skill rslib-best-practices

    All CLI flags supported by create-rslib:

    Usage: create-rslib [dir] [options]
    
    Options:
    
      -h, --help            display help for command
      -d, --dir <dir>       create project in specified directory
      -t, --template <tpl>  specify the template to use
      --tools <tool>        add additional tools, comma separated
      --skill <skill>       add optional skills, comma separated
      --override            override files in target directory
      --packageName <name>  specify the package name
    
    Available templates:
      node-dual-js, node-dual-ts, node-esm-js, node-esm-ts, react-js, react-ts, vue-js, vue-ts, svelte-js, svelte-ts
    
    Optional tools:
      react-compiler, eslint, rslint, biome, prettier, rspress, storybook
    
    Optional skills:
      rslib-best-practices, rstest-best-practices, rspress-custom-theme, rspress-description-generator

    Migrate from existing projects

    To migrate from an existing project to Rslib, refer to the following guides:

    Other projects

    For other types of projects, you can manually install the @rslib/core package:

    npm
    yarn
    pnpm
    bun
    deno
    npm add @rslib/core -D

    Then refer to the guide and documentation to enable the features you need: