close

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 the creation process, you can choose whether to add optional tools such as TypeScript, ESLint, etc.

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

Optional tools

create-rslib can help you set up some commonly used tools, including Biome, ESLint, Prettier, Rspress, Storybook and Rstest. Use the arrow keys to navigate and the space bar to select. Press Enter without selecting anything to skip these tools.

  • Rspress is available for React + TypeScript template, used for generating component documentation sites.
  • Storybook is available for web targeted templates (React, Vue), used for component development and preview.
  • Rstest is available for all templates, used for testing.
◆  Select additional tools (Use <space> to select, <enter> to continue)
│  ◻ Biome - linting & formatting
│  ◻ ESLint - linting
│  ◻ Prettier - formatting
│  ◻ Rspress - documentation
│  ◻ Storybook - component development
│  ◻ Rstest - testing
Tip

Biome provides similar linting and formatting features to ESLint and Prettier. If you select Biome, you typically won't need to choose ESLint or Prettier as well.

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 rstest,biome

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
  --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

Optional tools:
  biome, eslint, prettier, rspress, storybook, rstest

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: