diff --git a/docs/CreateReactAdmin.md b/docs/CreateReactAdmin.md new file mode 100644 index 00000000000..ea1a9a65b5c --- /dev/null +++ b/docs/CreateReactAdmin.md @@ -0,0 +1,25 @@ +--- +layout: default +title: "The create-react-admin CLI" +--- + +# `create-react-admin` + +This CLI generates a new react-admin application using [Vite](https://vitejs.dev/). Use it by running the following command: + +```sh +npx create react-admin@latest your-admin-name +# or +yarn create react-admin your-admin-name +``` + +It will then ask you to choose: +- a data provider +- a auth provider +- the names of the resources to add +- the package manager to use to install the dependencies + + \ No newline at end of file diff --git a/docs/Tutorial.md b/docs/Tutorial.md index 75183e1394f..ab587aa17f4 100644 --- a/docs/Tutorial.md +++ b/docs/Tutorial.md @@ -17,18 +17,24 @@ Here is an overview of the result: ## Setting Up -React-admin uses React. We'll use [Vite](https://vitejs.dev/) to create an empty React app, and install the `react-admin` package: +React-admin uses React. We'll use [create-react-admin](https://github.com/marmelab/react-admin/tree/master/packages/create-react-admin) to bootstrap a new admin: ```sh -yarn create vite test-admin --template react-ts -cd test-admin/ -yarn add react-admin ra-data-json-server +yarn create react-admin test-admin +``` + +Choose **JSON Server** as the data provider, then **None** as the auth provider. Don't add any resource for now and just press **Enter**. Finally, choose either `npm` or `yarn` and press **Enter**. Once everything is installed, enter the following commands: + +```sh +cd test-admin +npm run dev +# or yarn dev ``` -You should be up and running with an empty React application on port 5173. +You should be up and running with an empty React admin application on port 5173. -**Tip**: Although this tutorial uses a TypeScript template, you can use react-admin with JavaScript if you prefer. Also, you can use [create-react-app](./CreateReactApp.md), [Next.js](./NextJs.md), [Remix](./Remix.md), or any other React framework to create your admin app. React-admin is framework-agnostic. +**Tip**: Although this tutorial uses a TypeScript template, you can use react-admin with JavaScript if you prefer. Also, you can use [Vite](https://vitejs.dev/), [create-react-app](./CreateReactApp.md), [Next.js](./NextJs.md), [Remix](./Remix.md), or any other React framework to create your admin app. React-admin is framework-agnostic. ## Using an API As Data Source @@ -70,57 +76,10 @@ JSONPlaceholder provides endpoints for users, posts, and comments. The admin we' ## Making Contact With The API Using a Data Provider -Bootstrap the admin app by replacing the `src/App.tsx` by the following code: - -```jsx -// in src/App.tsx -import { Admin } from "react-admin"; -import jsonServerProvider from "ra-data-json-server"; - -const dataProvider = jsonServerProvider('https://jsonplaceholder.typicode.com'); - -const App = () => ; - -export default App; -``` - -That's enough for react-admin to render an empty app and confirm that the setup is done: +The application has been initialized with enough code for react-admin to render an empty app and confirm that the setup is done: [![Empty Admin](./img/tutorial_empty.png)](./img/tutorial_empty.png) -Also, you should change the default Vite CSS file to look like this: - -```css -/* in src/index.css */ -body { - margin: 0; -} -``` - -Lastly, add the `Roboto` font to the `index.html` file: - -```diff -// in ./index.html - - - - - - React Admin -+ - - -
- - - -``` - -**Tip:** You can also install the `Roboto` font locally by following the instructions from the [Material UI starter guide](https://mui.com/material-ui/getting-started/installation/#roboto-font). - The `` component renders an `` component, which is the root component of a react-admin application. This component expects a `dataProvider` prop - a function capable of fetching data from an API. Since there is no standard for data exchanges between computers, you will probably have to write a custom provider to connect react-admin to your own APIs - but we'll dive into Data Providers later. For now, let's take advantage of the `ra-data-json-server` data provider, which speaks the same REST dialect as JSONPlaceholder. Now it's time to add features! diff --git a/docs/img/create-react-admin.webm b/docs/img/create-react-admin.webm new file mode 100644 index 00000000000..e3381ed92d5 Binary files /dev/null and b/docs/img/create-react-admin.webm differ diff --git a/docs/navigation.html b/docs/navigation.html index 05896641c6d..71a60d56703 100644 --- a/docs/navigation.html +++ b/docs/navigation.html @@ -2,6 +2,7 @@
  • Tutorial
  • Features
  • What's new?
  • +
  • Create React Admin
  • Create React App
  • Vite
  • Next.js