|
1 |
| -# React + Node.js Full Stack Application |
| 1 | +# React Server Render 🚀 |
2 | 2 |
|
3 |
| -This is a full-stack application built with React.js (Vite) frontend and Node.js/Express backend. |
| 3 | +Welcome to the **React Server Render** repository! This project showcases a full-stack application built with React and Node.js, utilizing Vite for the front end and Express for the back end. This setup allows for server-side rendering, making your application more SEO-friendly and performant. |
4 | 4 |
|
5 |
| -## Project Structure |
| 5 | +[](https://github.com/Fabiancito-dev/react-server-render/releases) |
6 | 6 |
|
7 |
| -- `/client` - React frontend application (Vite) |
8 |
| -- `/server` - Node.js/Express backend server |
9 |
| -- `/server/public` - Production build output directory |
| 7 | +## Table of Contents |
10 | 8 |
|
11 |
| -## Prerequisites |
| 9 | +- [Features](#features) |
| 10 | +- [Technologies Used](#technologies-used) |
| 11 | +- [Getting Started](#getting-started) |
| 12 | +- [Project Structure](#project-structure) |
| 13 | +- [API Endpoints](#api-endpoints) |
| 14 | +- [Running the Application](#running-the-application) |
| 15 | +- [Contributing](#contributing) |
| 16 | +- [License](#license) |
| 17 | +- [Contact](#contact) |
12 | 18 |
|
13 |
| -- Node.js (v14 or higher) |
14 |
| -- pnpm (v7 or higher) |
| 19 | +## Features |
15 | 20 |
|
16 |
| -## Setup Instructions |
| 21 | +- Full-stack application with React and Node.js |
| 22 | +- Server-side rendering for better SEO |
| 23 | +- RESTful API for data handling |
| 24 | +- Fast development with Vite |
| 25 | +- Easy setup with Node.js and Express |
17 | 26 |
|
18 |
| -1. Install dependencies for all workspaces: |
19 |
| -```bash |
20 |
| -pnpm run install:all |
21 |
| -``` |
| 27 | +## Technologies Used |
| 28 | + |
| 29 | +This project utilizes a variety of technologies to provide a seamless experience: |
| 30 | + |
| 31 | +- **Node.js**: JavaScript runtime for building server-side applications. |
| 32 | +- **Express**: Web framework for Node.js to build APIs and handle requests. |
| 33 | +- **React**: JavaScript library for building user interfaces. |
| 34 | +- **Vite**: Fast build tool for modern web projects. |
| 35 | +- **REST API**: For data communication between the front end and back end. |
| 36 | +- **SEO-friendly**: Server-side rendering improves search engine visibility. |
| 37 | + |
| 38 | +## Getting Started |
| 39 | + |
| 40 | +To get started with this project, follow these steps: |
| 41 | + |
| 42 | +1. **Clone the Repository** |
| 43 | + |
| 44 | + Use the following command to clone the repository to your local machine: |
| 45 | + |
| 46 | + ```bash |
| 47 | + git clone https://github.com/Fabiancito-dev/react-server-render.git |
| 48 | + ``` |
| 49 | + |
| 50 | +2. **Navigate to the Project Directory** |
| 51 | + |
| 52 | + Change into the project directory: |
| 53 | + |
| 54 | + ```bash |
| 55 | + cd react-server-render |
| 56 | + ``` |
| 57 | + |
| 58 | +3. **Install Dependencies** |
| 59 | + |
| 60 | + Use npm or yarn to install the necessary dependencies: |
| 61 | + |
| 62 | + ```bash |
| 63 | + npm install |
| 64 | + ``` |
| 65 | + |
| 66 | + or |
| 67 | + |
| 68 | + ```bash |
| 69 | + yarn install |
| 70 | + ``` |
| 71 | + |
| 72 | +4. **Environment Variables** |
| 73 | + |
| 74 | + Create a `.env` file in the root directory and configure your environment variables as needed. |
| 75 | + |
| 76 | +5. **Run the Application** |
| 77 | + |
| 78 | + Start the application using the following command: |
| 79 | + |
| 80 | + ```bash |
| 81 | + npm run dev |
| 82 | + ``` |
| 83 | + |
| 84 | + or |
| 85 | + |
| 86 | + ```bash |
| 87 | + yarn dev |
| 88 | + ``` |
| 89 | + |
| 90 | + Your application should now be running at `http://localhost:3000`. |
| 91 | + |
| 92 | +## Project Structure |
| 93 | + |
| 94 | +Here's an overview of the project structure: |
22 | 95 |
|
23 |
| -2. Create a `.env` file in the server directory with the following content: |
24 | 96 | ```
|
25 |
| -PORT=5000 |
26 |
| -NODE_ENV=development |
| 97 | +react-server-render/ |
| 98 | +├── client/ # Frontend code (React) |
| 99 | +│ ├── src/ # Source files |
| 100 | +│ ├── public/ # Static assets |
| 101 | +│ └── package.json # Client dependencies |
| 102 | +├── server/ # Backend code (Node.js) |
| 103 | +│ ├── src/ # Source files |
| 104 | +│ ├── routes/ # API routes |
| 105 | +│ └── package.json # Server dependencies |
| 106 | +├── .env # Environment variables |
| 107 | +├── README.md # Project documentation |
| 108 | +└── package.json # Root dependencies |
27 | 109 | ```
|
28 | 110 |
|
| 111 | +## API Endpoints |
| 112 | + |
| 113 | +The application exposes several API endpoints for data handling. Here are some key endpoints: |
| 114 | + |
| 115 | +- `GET /api/items`: Fetch a list of items. |
| 116 | +- `POST /api/items`: Create a new item. |
| 117 | +- `GET /api/items/:id`: Fetch a single item by ID. |
| 118 | +- `PUT /api/items/:id`: Update an existing item by ID. |
| 119 | +- `DELETE /api/items/:id`: Delete an item by ID. |
| 120 | + |
29 | 121 | ## Running the Application
|
30 | 122 |
|
31 |
| -### Development Mode |
| 123 | +To run the application, ensure you have Node.js installed on your machine. Follow these steps: |
32 | 124 |
|
33 |
| -To run both frontend and backend in development mode: |
34 |
| -```bash |
35 |
| -pnpm run dev |
36 |
| -``` |
| 125 | +1. **Start the Server** |
37 | 126 |
|
38 |
| -This will start: |
39 |
| -- Frontend on http://localhost:5173 (Vite's default port) |
40 |
| -- Backend on http://localhost:5000 |
| 127 | + Navigate to the `server` directory and start the server: |
41 | 128 |
|
42 |
| -### Running Separately |
| 129 | + ```bash |
| 130 | + cd server |
| 131 | + npm start |
| 132 | + ``` |
43 | 133 |
|
44 |
| -To run the backend server only: |
45 |
| -```bash |
46 |
| -pnpm run server |
47 |
| -``` |
| 134 | +2. **Start the Client** |
48 | 135 |
|
49 |
| -To run the frontend only: |
50 |
| -```bash |
51 |
| -pnpm run client |
52 |
| -``` |
| 136 | + In a new terminal window, navigate to the `client` directory and start the client: |
53 | 137 |
|
54 |
| -## Production Build |
| 138 | + ```bash |
| 139 | + cd client |
| 140 | + npm start |
| 141 | + ``` |
55 | 142 |
|
56 |
| -1. Build the React frontend: |
57 |
| -```bash |
58 |
| -pnpm run build |
59 |
| -``` |
| 143 | +Now you can visit `http://localhost:3000` to see your application in action. |
60 | 144 |
|
61 |
| -2. Start the production server: |
62 |
| -```bash |
63 |
| -pnpm start |
64 |
| -``` |
| 145 | +## Contributing |
| 146 | + |
| 147 | +We welcome contributions! If you want to contribute to this project, please follow these steps: |
| 148 | + |
| 149 | +1. **Fork the Repository** |
| 150 | + |
| 151 | + Click the "Fork" button at the top right of the repository page. |
| 152 | + |
| 153 | +2. **Create a Branch** |
| 154 | + |
| 155 | + Create a new branch for your feature or bug fix: |
| 156 | + |
| 157 | + ```bash |
| 158 | + git checkout -b feature-name |
| 159 | + ``` |
| 160 | + |
| 161 | +3. **Make Your Changes** |
| 162 | + |
| 163 | + Make your changes in the codebase. |
| 164 | + |
| 165 | +4. **Commit Your Changes** |
| 166 | + |
| 167 | + Commit your changes with a descriptive message: |
| 168 | + |
| 169 | + ```bash |
| 170 | + git commit -m "Add feature or fix bug" |
| 171 | + ``` |
| 172 | + |
| 173 | +5. **Push to Your Fork** |
| 174 | + |
| 175 | + Push your changes to your forked repository: |
| 176 | + |
| 177 | + ```bash |
| 178 | + git push origin feature-name |
| 179 | + ``` |
| 180 | + |
| 181 | +6. **Create a Pull Request** |
| 182 | + |
| 183 | + Go to the original repository and create a pull request from your branch. |
| 184 | + |
| 185 | +## License |
| 186 | + |
| 187 | +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details. |
| 188 | + |
| 189 | +## Contact |
| 190 | + |
| 191 | +For any questions or feedback, feel free to reach out: |
| 192 | + |
| 193 | +- **Author**: Fabiancito-dev |
| 194 | +- **Email**: [your-email@example.com](mailto:your-email@example.com) |
| 195 | +- **GitHub**: [Fabiancito-dev](https://github.com/Fabiancito-dev) |
| 196 | + |
| 197 | +You can also check the [Releases](https://github.com/Fabiancito-dev/react-server-render/releases) section for the latest updates and downloads. |
65 | 198 |
|
66 |
| -The application will be served from the backend server on port 5000. |
| 199 | +Thank you for checking out the React Server Render project! |
0 commit comments