How to start a backend with Vertx and a React frontend with ViteJS.
git clone git@github.com:ccreusat/demo-monorepo-vertx-react.git
Install root and frontend dependencies:
yarn && yarn start
You can start server on Port 3001
with Gradle:
yarn server
For this example, /api/message
will send this message:
Hello React from Vert.x!
You can check if route is working fine with:
- HTTPie in your terminal
http :3001/api/message
- Using route in your browser
http://localhost:3001/api/message
Hello React from Vert.x!
You can start React app on Port 3000
:
yarn client
You should see Hello React from Vert.x!
inside your client app.
ViteJS Server will listen the Port 3001
on /api
route:
server: {
proxy: {
"/api": "http://localhost:3001",
},
host: "0.0.0.0",
port: 3000,
open: true,
}
The build task will create the frontend application and add the bundle to: build/classes/java/main/webroot
yarn server
Browse to http://localhost:3001
and you should see the build version.