关于React与Angular开发部署的若干技术疑问
Hey there! Let's break down your questions one by one—they're all super common when you're getting started with React, so great thinking to ask these up front.
1. Are all websites built with frameworks like React or Angular?
Absolutely not! There are still tons of websites built with plain HTML, CSS, and JavaScript. This is especially true for simple static pages (like small business landing pages, personal blogs, or tooling micro-sites) where the extra overhead of a framework isn't needed. Frameworks exist to streamline development for complex applications with lots of interactivity, state management, and routing—but they're by no means a requirement. Many small teams or side projects start with native tech first, only adding a framework if the project grows in complexity.
2. Are these frameworks only for Single-Page Applications (SPAs)?
Nope! React and Angular are absolutely capable of powering Multi-Page Applications (MPAs) too. For example:
- With React, you can use tools like Next.js to build MPAs with server-side rendering (SSR) or static site generation (SSG), where each page has its own route and independent rendering logic.
- Angular has Angular Universal for SSR-enabled MPAs.
- You can even progressively embed React components into existing traditional multi-page sites—like adding a dynamic form or interactive widget to a static HTML page without rewriting the entire site. This is a popular approach for updating legacy projects incrementally.
3. Can I deploy a React app using a Node.js server?
Definitely! There are a few common ways to do this:
- For static React apps (after running
npm run buildto generate optimized static files in abuildordistfolder), you can use Node.js frameworks like Express to serve these static files. Here's a quick example:
const express = require('express'); const path = require('path'); const app = express(); // Serve static files from the build directory app.use(express.static(path.join(__dirname, 'build'))); // Catch all routes and return the main index.html (for SPA routing) app.get('*', (req, res) => { res.sendFile(path.join(__dirname, 'build', 'index.html')); }); app.listen(3000, () => { console.log('Server running on http://localhost:3000'); });
- For SSR/SSG React apps (like Next.js projects), you can deploy them directly as Node.js applications, or export static files and serve them via Node.js just like the example above.
4. Is the traditional approach of building static pages with HTML/CSS/JS and deploying via Apache still used today?
Absolutely! This approach is still widely adopted for its simplicity, low cost, and minimal overhead. It's perfect for projects that don't need complex interactivity or state management—think personal portfolios, static blogs, or small informational sites. Even modern static site generators (like Jekyll or Hugo) follow this core idea: they generate static HTML/CSS/JS files that you can deploy to Apache, Nginx, or even static hosting services like Netlify or Vercel. Many developers still prefer this method when the project requirements are straightforward, as it avoids the learning curve and build processes associated with frameworks.
内容的提问来源于stack exchange,提问作者Austris

