Skip to content

Commit b41b43d

Browse files
authored
Merge pull request #10566 from marmelab/rewrite_create-react-admin_doc
[Doc] Rewrite `create-react-admin` documentation
2 parents c0cb320 + 7c80e25 commit b41b43d

File tree

2 files changed

+83
-10
lines changed

2 files changed

+83
-10
lines changed

docs/CreateReactAdmin.md

Lines changed: 79 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,38 @@ title: "The create-react-admin CLI"
55

66
# `create-react-admin`
77

8-
`create-react-admin` is a package that generates a react-admin app scaffolding using [Vite](https://vitejs.dev/). It is designed to work on most setups and produces predictable and consistent results. It's the preferred way to create a new react-admin application.
8+
Use `create-react-admin` to quickly bootstrap a react-admin project using [Vite](https://vitejs.dev/). It's the preferred way to create a new react-admin application.
99

1010
<iframe src="https://www.youtube-nocookie.com/embed/i_TbS7quzww" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen style="aspect-ratio: 16 / 9;width:100%;margin-bottom:1em;"></iframe>
1111

1212
## Usage
1313

14-
Use it by running the following command:
15-
1614
```sh
1715
npx create-react-admin@latest your-admin-name
18-
# or
19-
yarn create react-admin your-admin-name
2016
```
2117

22-
The terminal will then ask you to choose:
23-
- a data provider
24-
- an auth provider
25-
- the names of the resources to add
26-
- the package manager to use to install the dependencies
18+
This will create an empty react-admin application in a directory called `your-admin-name`.
19+
20+
**Tip**: You can replace `npx` with `npm`, `yarn`, or `bun`
21+
22+
## Options
23+
24+
The command accepts the following options:
25+
26+
* `--interactive`: Enable the CLI interactive mode
27+
* `--data-provider`: Set the data provider to use ("data-fakerest", "data-simple-rest", "data-json-server", "supabase" or "none")
28+
* `--auth-provider`: Set the auth provider to use ("local-auth-provider" or "none")
29+
* `--resource`: Add a resource that will be initialized with guessers (can be used multiple times). Set to "skip" to bypass the interactive resource step.
30+
* `--install`: Set the package manager to use for installing dependencies ("yarn", "npm", "bun" or "skip" to bypass the interactive install step)
31+
32+
## `--interactive`
33+
34+
When using this option, the terminal will ask you to choose:
35+
36+
* a [data provider](#data-provider)
37+
* an [auth provider](#auth-provider)
38+
* the names of the [resources](#resources) to add
39+
* the [package manager](#package-manager) to use to install the dependencies
2740

2841
<video controls autoplay playsinline muted loop>
2942
<source src="./img/create-react-admin.webm" type="video/webm"/>
@@ -39,4 +52,60 @@ Once the installation is complete, you can run the app with:
3952
npm run dev
4053
# or
4154
yarn dev
55+
# or
56+
bun run dev
57+
```
58+
59+
## `--data-provider`
60+
61+
`create-react-admin` currently supports five presets for the application's data provider:
62+
63+
* `fakerest`: A client-side data provider that use a JSON object for data, powered by [FakeRest](https://github.com/marmelab/FakeRest).
64+
* `json-server`: A data provider based on the [JSON Server](https://github.com/typicode/json-server) API
65+
* `simple-rest`: A data provider for [simple REST APIs](https://github.com/marmelab/react-admin/tree/master/packages/ra-data-simple-rest)
66+
* `supabase`: A data provider for [Supabase](https://github.com/marmelab/ra-supabase/tree/main/packages/ra-supabase). The auth-provider and resources steps will be skipped.
67+
* `none` (default): You'll configure the data provider myself.
68+
69+
You can set your data provider directly with the `--data-provider` option:
70+
71+
```sh
72+
npx create-react-admin@latest your-admin-name --data-provider json-server
73+
```
74+
75+
## `--auth-provider`
76+
77+
`create-react-admin` currently supports two presets to set the application's auth provider which are:
78+
79+
* `local-auth-provider`: Hard coded username/password.
80+
* `none` (default): No authProvider.
81+
82+
You can set your auth provider directly with the `--auth-provider` option:
83+
84+
```sh
85+
npx create-react-admin@latest your-admin-name --auth-provider local-auth-provider
86+
```
87+
88+
## `--resource`
89+
90+
`create-react-admin` creates an empty app by default. You can initialize CRUD pages for some resources with the `--resource` option:
91+
92+
```sh
93+
npx create-react-admin@latest your-admin-name --resource posts --resource comments
94+
```
95+
96+
**Warning:** the `--resource` flag is incompatible with a `--data-provider supabase` due to a specific [`<AdminGuesser>` component](https://github.com/marmelab/ra-supabase/tree/main/packages/ra-supabase#usage) from `ra-supabase`.
97+
98+
## `--install`
99+
100+
`create-react-admin` can install dependencies using any of the following package managers:
101+
102+
* `npm` (default)
103+
* `yarn`
104+
* `bun`
105+
* `none` (if you want to install dependencies yourself)
106+
107+
You choose an alternative package manager with the `--install` option:
108+
109+
```sh
110+
npx create-react-admin@latest your-admin-name --install bun
42111
```

packages/create-react-admin/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ A CLI to bootstrap a new react-admin application.
77
```sh
88
npm create react-admin@latest my-app
99
# or
10+
npx create react-admin@latest my-app
11+
# or
1012
yarn create react-admin my-app
13+
# or
14+
bun create react-admin my-app
1115
```
1216

1317
You'll be asked to choose a data provider (optional), an auth provider (optional). You may also setup the resources you want initially.

0 commit comments

Comments
 (0)