This is a small React single-page application that works with the Simple Events Handler backend (https://github.com/arimatakao/simple-events-handler). The client provides a minimal UI to create and list events and is intentionally lightweight so it can be served as a static site.
Highlights
- Create and list events using a simple form and list UI
- Built with Create React App for quick development and easy production builds
- Node.js (LTS recommended, e.g. 14/16/18/20)
- npm (bundled with Node) or yarn
- Install dependencies
npm install
# or
yarn- Run the development server
npm start
# or
yarn startOpen http://localhost:3000 in your browser. The dev server supports hot reload.
The client communicates with an events API. By default the API base URL is read from src/api.js. In development you can override it by setting the REACT_APP_API_BASE environment variable (Create React App exposes variables prefixed with REACT_APP_ to the frontend).
Example — create a .env file at the project root:
# .env
REACT_APP_API_BASE=http://localhost:4000Restart the dev server after changing environment variables.
If you prefer to edit the constant directly, check src/api.js for the API base constant used by services/events.js.
npm start— run the app in development mode (dev server on :3000)npm run build— create an optimized production build in thebuild/foldernpm test— run tests (if any)
Use yarn equivalents if you use Yarn.
src/— React source filesindex.js— app entryApp.js— main componentcomponents/AddEventForm.js— form to create eventscomponents/EventList.js— displays eventsservices/events.js— API helper (fetch/post events)api.js— central API base constant
public/— static html and assets used by CRAbuild/— production output (afternpm run build)
The client uses services/events.js to call the backend. Typical endpoints:
- GET /events — fetch all events
- POST /events — create a new event (JSON body)
If your backend requires authentication, custom headers, or different routes, update services/events.js accordingly.
Create an optimized production build:
npm run build
# or
yarn buildDeploy the contents of the build/ directory to any static host (Netlify, Vercel, Amazon S3, GitHub Pages, etc.).
-
Dev server won't start:
- Ensure Node and npm/yarn are installed and on supported versions.
- Remove
node_modulesand reinstall:rm -rf node_modules && npm install.
-
The app can't reach the API:
- Confirm
REACT_APP_API_BASEorsrc/api.jspoints to your backend URL. - Open the browser DevTools network tab to inspect requests and the URLs used.
- Confirm
-
CORS errors:
- Ensure the backend allows cross-origin requests from
http://localhost:3000while developing.
- Ensure the backend allows cross-origin requests from
-
Unexpected build output or runtime errors after editing:
- Stop the dev server and restart it. For production builds, delete
build/and re-runnpm run build.
- Stop the dev server and restart it. For production builds, delete
-
The UI is intentionally small:
AddEventFormhandles creating events andEventListdisplays them. -
The API helper is in
src/services/events.js. Consider adding retries or better error handling if you integrate with flaky backends. -
Suggested small improvements:
- Add a
.env.exampleshowingREACT_APP_API_BASEusage - Add basic unit tests for components
- Add a CONTRIBUTING.md with development workflows
This repository includes a multi-stage
Dockerfilethat builds the React app and serves it with nginx.Build the image:
docker build -t simple-events-client:latest .Run the container (serves on port 80):
docker run --rm --env-file ./.env.example -p 8082:80 simple-events-client:latest
Open http://localhost:8082 to view the app.
Notes:
- The Dockerfile uses a Node build stage and a lightweight nginx runtime.
- Use
--build-argor updatesrc/api.js/ environment variables if you need to point the frontend to a different backend.
- Add a