This tutorial guides you through building a full-stack application using FastAPI for the back-end, React.js with Vite for the front-end, and Material-UI for a clean user interface, all with TypeScript. The chosen stack is ideal for modern applications due to FastAPI's speed and asynchronous capabilities, React and Vite's fast development environment and modular frontend structure, and MUI's polished and professional look. The project structure consists of a backend folder for the FastAPI app and a frontend folder for the React app with Vite.
To set up FastAPI, you need to create a new directory, install poetry, and add FastAPI and uvicorn dependencies. Then, you can create a main.py file with a basic FastAPI app and run the server using uvicorn. For the front-end, you need to create a new directory, install Vite and React with TypeScript, and add MUI and axios dependencies. You also need to add proxy settings to the vite.config.ts file to proxy API requests to the FastAPI server.
To connect React to FastAPI, you need to create an App component that makes an API call to the FastAPI server using axios and displays the response message. Finally, you can run both the back-end and front-end servers and access the app at http://localhost:3000. This tutorial provides a basic setup for a full-stack app, and you can also check out a full boilerplate with features like user authentication and database integration for production readiness and startup projects.
dev.to
dev.to
Create attached notes ...
