The purpose of this project is to demonstrate how to run a React-admin client using Soul as a REST API service. Soul is an open-source REST API wrapper that exposes an SQLite database to any client.
There are two ways to run this project locally:
- Run Soul and the React Admin client independently
- Run the React Admin client as an extension of Soul.
-
Go to the root folder of the project and install the npm packages by running:
npm install
-
Copy the environment variables from the
.env.sample
file and modify the variables by running:cp .env.sample .env
PORT
: The port on which the Soul server runs.VITE_API_URL
: The API URL of Soul, which should behttp://localhost:<PORT>/api/tables
.EXTENSIONS
: The absolute path location of the_extensions
folder
-
Start the Soul server by running:
npm run dev:soul
-
Start your React-admin client in another terminal by running:
npm run dev:client
-
To check if the app is working, use the following URL in your browser:
http://localhost:<port_of_react-admin>
- Build the react admin client
npm run build
- Run the react admin app as a soul extension
npm run dev:soul-client
- To check if the app is working, use the following URL in your browser:
http://localhost:<port>/api/client
You can deploy this project to Heroku. You can use either the Heroku CLI or create a pipeline in Heroku to automatically deploy the project when a commit is pushed to a PR.
-
Create a new Heroku app in the Heroku dashboard.
-
Install the Heroku CLI on your local machine.
-
Log in to Heroku from your CLI by running:
heroku login
-
Create a new Heroku Git remote by running the following command:
heroku git:remote -a <your-app-name>
-
Push your code to the Heroku Git remote by running the following command:
git push heroku master
-
Go to the Heroku dashboard's settings tab and pass the Soul API URL to the environment variable. Your
VITE_API_URL
should be something like this:VITE_API_URL=https://<your-app-name>.herokuapp.com/api/tables
Note: make sure to replace
<your-app-name>
with the actual name of your Heroku app. -
Copy the link of the project from the Heroku dashboard and verify if it is working. You can add /api/client to the link to check the React admin client or /api/tables to check the Soul API. Here are some examples:
-
React admin app link:
https://<your-app-name>.herokuapp.com/api/client
-
Soul API link:
https://<your-app-name>.herokuapp.com/api/tables
-
Note: Replace with the actual name of your Heroku app.