Skip to content

Commit 26a4c0c

Browse files
committed
Review
1 parent 08d9720 commit 26a4c0c

File tree

2 files changed

+43
-29
lines changed

2 files changed

+43
-29
lines changed

docs/Deploy.md

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
11
---
22
layout: default
3-
title: "Deploy React-admin"
3+
title: "Deployment"
44
---
55

6-
# Deploy React-admin
6+
# Deployment
77

8-
You have created an awesome React-admin application. Well done! But now, you want to deploy your application in production so users can actually use it.
8+
You can use react-admin with Vite.js, Next.js, Remix, or any other React platform. Each of these platforms has its own way to deploy your application:
99

10-
## Single Page Application
10+
- [Vite deployment guide](https://vite.dev/guide/static-deploy.html)
11+
- [Next.js deployment guide](https://nextjs.org/docs/pages/getting-started/deploying)
12+
- [Remix deployment guide](https://remix.run/docs/en/main/guides/deployment)
1113

12-
React-admin is a framework to build [Single Page Applications](https://developer.mozilla.org/en-US/docs/Glossary/SPA). It means that your app can be served by a simple static web server.
14+
The general principles are the same. This tutorial explains how to deploy your React-admin application with [`create-react-admin`](./CreateReactAdmin.md) (powered by Vite.js).
1315

14-
**Warning**: If you chose Next.js or Remix, you **have to use a dynamic web server** (e.g. CloudFlare pages, Vercel, etc.).
16+
## Building The Single Page Application
1517

16-
With the default configuration of React-admin, that you can have using [`create-react-admin`](./CreateReactAdmin.md), you can run `yarn build` or `npm run build` to compile your application with [`vite`](https://vite.dev).
18+
React-admin uses the [Single Page Applications](./Architecture.md#single-page-application) architecture. It means that your app can be bundled as a single JavaScript file and served by a simple static web server.
1719

18-
This builds your application in the `dist` directory at the application root. Let's have a look to what's in there:
20+
In an application initialized with `create-react-admin`, you can run the `build` command to compile your application:
21+
22+
```sh
23+
npm run build
24+
# or
25+
yarn build
26+
```
27+
28+
This creates a few files in the `dist` directory. Let's have a look to what's in there:
1929

2030
```tree
2131
dist/
@@ -26,18 +36,22 @@ dist/
2636
└ manifest.json
2737
```
2838

29-
As you can see, your app is contained in a single Javascript file, used in a simple `index.html`. To deploy your application, you just need to serve this directory with all URLs handled by `index.html`.
39+
The entry point is `index.html`. It contains a `<script>` tag that loads the app from the `assets` directory.
40+
41+
To deploy your application, you just need to serve this `dist` directory with all URLs handled by `index.html`.
3042

31-
There are multiple ways to deploy your app automatically to various hosts which does not require you to setup a web server manually. Some of these are addressed in this page.
43+
There are multiple ways to do so, let's see a few of them.
3244

33-
## Deploy With GitHub Actions And GitHub Pages
45+
## Deploying To GitHub Pages
3446

35-
You can deploy your application with [GitHub Pages](https://pages.github.com) by setting up a [GitHub Actions](https://github.com/features/actions) workflow. To set it up, you need to [configure the source of your GitHub Pages to GitHub Actions](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow).
47+
[GitHub Pages](https://pages.github.com) can serve static assets from a GitHub repository. You can automate the build step by setting up a [GitHub Actions](https://github.com/features/actions) workflow.
3648

37-
Then, initialize a new workflow in `.github/workflows/admin.yml` with the following content:
49+
First, [configure the source of your GitHub Pages to GitHub Actions](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow).
50+
51+
Then, initialize a new workflow in `.github/workflows/deploy.yml` with the following content:
3852

3953
```yaml
40-
name: Build and deploy React-admin
54+
name: Build and deploy
4155

4256
on:
4357
push:
@@ -46,7 +60,7 @@ on:
4660

4761
jobs:
4862
build:
49-
name: Build the admin panel to be deployed
63+
name: Build the single-page application
5064
runs-on: ubuntu-latest
5165
environment: github-pages
5266
steps:
@@ -71,7 +85,7 @@ jobs:
7185
path: dist/
7286

7387
deploy:
74-
name: Deploy React-admin application to GitHub Pages
88+
name: Deploy to GitHub Pages
7589
runs-on: ubuntu-latest
7690
needs: build
7791

@@ -90,14 +104,14 @@ jobs:
90104
uses: actions/deploy-pages@v4
91105
```
92106
93-
This workflow will run everytime you push or merge something in the main branch of your repository. You can find the URL of the deployed website in `Settings > Pages` in your GitHub repository.
94-
107+
This workflow will run every time you push or merge something in the main branch of your repository. You can find the URL of the deployed website in `Settings > Pages` in your GitHub repository.
95108

96-
## Deploy With GitHub Actions to Cloudflare
109+
## Deploying to Cloudflare
97110

98111
To deploy to [Cloudflare Pages](https://pages.cloudflare.com/), you need to have a [Cloudflare](https://www.cloudflare.com/) account. First, retrieve your account ID from Cloudflare, the documentation on how to retrieve it is available on the [Cloudflare documentation](https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/)
99112

100113
Then, create a new API token from your [Cloudflare Profile page](https://dash.cloudflare.com/profile/api-tokens):
114+
101115
- First click on `Create Token`
102116
- Then on the `Edit Cloudflare Workers` template
103117
- Select your organization inside the `Account Resources`
@@ -113,21 +127,21 @@ To create a new Cloudflare Page App, go to your Cloudflare dashboard, then on `C
113127

114128
Once you have configured your API token and retrieved your Account ID, you can setup the following secrets in your repository by going to `Settings > Secrets and variables > Actions` on your GitHub repository:
115129

116-
117130
```sh
118-
# Your Cloudlfare API token
131+
# Your Cloudflare API token
119132
CLOUDFLARE_API_TOKEN=
120133
121-
# Your Cloudlfare Account ID
134+
# Your Cloudflare Account ID
122135
CLOUDFLARE_ACCOUNT_ID=
123136
124-
# The Cloudflare Pages
137+
# The Cloudflare Pages project name
125138
CLOUDFLARE_PROJECT_NAME=
126139
```
127140

128-
Once your project has been configured, initialize a new workflow in your repository `.github/workflows/admin.yml` with the following content:
141+
Once your project has been configured, initialize a new workflow in your repository `.github/workflows/deploy.yml` with the following content:
142+
129143
```yml
130-
name: Build and deploy React-admin
144+
name: Build and deploy
131145
132146
on:
133147
push:
@@ -136,7 +150,7 @@ on:
136150
137151
jobs:
138152
build:
139-
name: Build the admin panel to be deployed
153+
name: Build the single-page application
140154
runs-on: ubuntu-latest
141155
steps:
142156
- uses: actions/checkout@v4
@@ -158,7 +172,7 @@ jobs:
158172
path: dist
159173
160174
deploy:
161-
name: Deploy React-admin Application to Cloudflare
175+
name: Deploy to Cloudflare
162176
runs-on: ubuntu-latest
163177
needs: build
164178
@@ -185,4 +199,4 @@ jobs:
185199
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
186200
```
187201

188-
Now, each time your code will be pushed to your main branch, an action will be started that will automatically deploy your app to your Cloudflare Pages app.
202+
Now, each time your code is pushed to the `main` branch, GitHub will automatically deploy your app to your Cloudflare Pages.

docs/navigation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<li {% if page.path == 'Vite.md' %} class="active" {% endif %}><a class="nav-link" href="./Vite.html">Vite</a></li>
1515
<li {% if page.path == 'NextJs.md' %} class="active" {% endif %}><a class="nav-link" href="./NextJs.html">Next.js</a></li>
1616
<li {% if page.path == 'Remix.md' %} class="active" {% endif %}><a class="nav-link" href="./Remix.html">Remix</a></li>
17-
<li {% if page.path == 'Deploy.md' %} class="active beginner" {% endif %}><a class="nav-link" href="./Deploy.html">Deploy</a></li>
17+
<li {% if page.path == 'Deploy.md' %} class="active beginner" {% endif %}><a class="nav-link" href="./Deploy.html">Deployment</a></li>
1818
</ul>
1919

2020
<ul><div>Guides & Concepts</div>

0 commit comments

Comments
 (0)