From this folder (project-template-react-rails-api), enter 'rails s' from the terminal window to start the server. Then, enter npm start --prefix frontend to start the frontend server.
This project is scaffolded so that you can build a React frontend and Rails backend together.
- Ruby 2.7.4
- NodeJS (v14 or higher), and npm
See Environment Setup below for instructions on installing these tools if you don't already have them.
Fork and clone this repository.
Then run:
bundle install
rails db:create
rails db:seed
npm install --prefix frontend
You can use the following commands to run the application:
rails s
: run the backend on http://localhost:3000npm start --prefix client
: run the frontend on http://localhost:4000rails start
: run the frontend and backend together with one command
Verify which version of Ruby you're running by entering this in the terminal:
ruby -v
Make sure that the Ruby version you're running is listed in the supported runtimes by Heroku. At the time of writing, supported versions are 2.6.8, 2.7.4, or 3.0.2. Our recommendation is 2.7.4, but make sure to check the site for the latest supported versions.
If it's not, you can use rvm
to install a newer version of Ruby:
rvm install 2.7.4 --default
You should also install the latest versions of bundler
and rails
:
gem install bundler
gem install rails
Verify you are running a recent version of Node with:
node -v
If your Node version is less than 14, update it with:
nvm install node
You can also update your npm version with:
npm i -g npm