Quick start
Setup environment
Before getting started, you will need to install Node.js >= 18.12.0, it is recommended to use the Node.js LTS version.
Check the current Node.js version with the following command:
If you do not have Node.js installed in current environment, or the installed version is too low, you can use nvm or fnm to install.
Here is an example of how to install via nvm:
Creating an Rslib project
Use create-rslib to create a new Rslib project. Run the following command:
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 initto initialize a Git repository. - Run
npm install(or your package manager's install command) to install dependencies. - Run
npm run devto start watch mode and begin development.
Templates
When creating a project, you can choose from the following templates provided by create-rslib:
Optional tools
create-rslib can help you set up some commonly used tools, including Biome, ESLint, Prettier, Rspress, Storybook, Rstest and Vitest. 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 / Vitest are available for all templates, used for testing.
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 .:
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:
All CLI flags supported by create-rslib:
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:
Then refer to the guide and documentation to enable the features you need:
- See CLI to learn about available CLI commands.
- See Configure Rslib to configure Rslib.
