React

> DOCUMENTATION

React Installation Guide

Get your React template running with Vite, React Router, and Tailwind CSS.

> Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js 16.0+Download here
  • npm (comes with Node.js) or yarn
  • A code editor like VS Code (recommended)
  • A modern web browser (Chrome, Firefox, Safari, or Edge)

To verify your installation:

terminal
node --version
npm --version

> Installation Steps

Step 1: Download Your Template

After downloading your template, extract the .zip file to your projects folder:

terminal
# Navigate to your projects directory
cd ~/Projects

# Extract the template (replace with your actual filename)
unzip aurora_spectrum_ai-technology-aurora-react.zip
cd aurora_spectrum_ai-technology-aurora

Package Contents:

  • src/pages/ — Page components (IndexPage.jsx, AboutPage.jsx, etc.)
  • src/components/ — Reusable UI components (Text, Button, Image, Link, etc.)
  • src/data/ — Content data file (content.js)
  • src/styles/ — Global CSS (globals.css)
  • src/App.jsx — Main app with routing
  • public/ — Static assets and index.html
  • tailwind.config.js — Tailwind CSS settings
  • package.json — Project dependencies

Step 2: Install Dependencies

Install all required packages using your preferred package manager:

Using npm (recommended):

terminal
npm install

Using yarn:

terminal
yarn install

What gets installed:

  • • React 18.x
  • • React Router DOM
  • • Vite (build tool)
  • • Tailwind CSS
  • • Lucide React (icons)
  • • PostCSS & Autoprefixer

Installation time: 1-2 minutes

Step 3: Start the Development Server

Launch the Vite development server:

terminal
npm run dev

Or with yarn: yarn dev

Expected output:

VITE v5.0.0  ready in 300 ms

➜  Local:   http://localhost:5173/
➜  Network: http://192.168.1.x:5173/
➜  press h + enter to show help

Features enabled:

  • • Hot Module Replacement (HMR) — instant updates
  • • Error overlay with source maps
  • • Optimized dependency pre-bundling
  • • Asset handling (images, fonts)

Step 4: View Your Site

Open your browser and navigate to:

Your React site is now running! Any changes you make will automatically appear in the browser.

> Building for Production

Create an optimized production build:

terminal
npm run build

This process:

  • 1. Bundles and minifies all JavaScript
  • 2. Optimizes CSS with purging unused styles
  • 3. Generates hashed filenames for caching
  • 4. Creates the dist/ folder

Preview the production build locally:

terminal
npm run preview

Build output example:

vite v5.0.0 building for production...
✓ 42 modules transformed.
dist/index.html                   0.5 kB │ gzip:  0.3 kB
dist/assets/index-a1b2c3d4.css   24.1 kB │ gzip:  5.2 kB
dist/assets/index-e5f6g7h8.js    89.3 kB │ gzip: 28.7 kB
✓ built in 2.34s

> Deployment Options

Option 1: Vercel (Recommended)

Easiest deployment — takes 2 minutes:

  1. Push your code to GitHub/GitLab/Bitbucket
  2. Go to vercel.com
  3. Click "Import Project"
  4. Select your repository
  5. Click "Deploy" (Vercel auto-detects Vite)

Your site is live! Get a free .vercel.app domain + automatic deployments.

Option 2: Netlify

  1. Build locally: npm run build
  2. Go to netlify.com
  3. Drag and drop the dist/ folder

Or connect your Git repository for automatic deployments.

Option 3: GitHub Pages

1. Add base path to vite.config.js:

vite.config.js
export default defineConfig({
  base: '/your-repo-name/',
  // ... rest of config
})

2. Build and deploy:

terminal
npm run build
npx gh-pages -d dist

Option 4: Docker + Nginx

Dockerfile
FROM node:18-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

> Customization Guide

Changing Colors & Branding

Edit tailwind.config.js:

tailwind.config.js
module.exports = {
  theme: {
    extend: {
      colors: {
        primary: '#0891B2',      // Your primary brand color
        secondary: '#F97316',    // Accent color
        accent: '#8B5CF6',       // Additional accent
      },
      fontFamily: {
        sans: ['Inter', 'sans-serif'],
        display: ['Poppins', 'sans-serif'],
      },
    },
  },
}

Adding Routes (React Router)

Routes are defined in src/App.jsx or src/main.jsx:

App.jsx
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import Home from './pages/Home';
import About from './pages/About';
import Services from './pages/Services'; // New page

function App() {
  return (
    <BrowserRouter>
      <Routes>
        <Route path="/" element={<Home />} />
        <Route path="/about" element={<About />} />
        <Route path="/services" element={<Services />} /> {/* New route */}
      </Routes>
    </BrowserRouter>
  );
}

Creating New Components

Create components in src/components/:

Button.jsx
// src/components/Button.jsx
export default function Button({ children, onClick, variant = 'primary' }) {
  const styles = {
    primary: 'bg-blue-600 hover:bg-blue-700 text-white',
    secondary: 'bg-gray-200 hover:bg-gray-300 text-gray-800',
  };
  
  return (
    <button
      onClick={onClick}
      className={`px-4 py-2 rounded-lg font-medium ${styles[variant]}`}
    >
      {children}
    </button>
  );
}

Environment Variables

Create a .env file in the root:

.env
VITE_API_URL=https://api.example.com
VITE_APP_TITLE=My React App

Access in your code:

terminal
const apiUrl = import.meta.env.VITE_API_URL;
const title = import.meta.env.VITE_APP_TITLE;

Note: Only variables prefixed with VITE_ are exposed to the browser.

> Troubleshooting

Error: Port 5173 is already in use

Option 1: Use a different port

terminal
npm run dev -- --port 3000

Option 2: Kill the existing process

terminal
# macOS/Linux
lsof -ti:5173 | xargs kill -9

# Windows
netstat -ano | findstr :5173
taskkill /PID <PID> /F

Error: Cannot find module 'react'

terminal
# Remove and reinstall dependencies
rm -rf node_modules package-lock.json
npm install

Problem: Production build shows blank page

  • Check browser console for errors (F12)
  • Verify base path in vite.config.js matches your deployment URL
  • For SPAs, configure your server to handle client-side routing

Problem: Components appear unstyled

  • Verify tailwind.config.js content paths include your src files
  • Check index.css has Tailwind directives
  • Restart the development server

Problem: Refreshing a route returns 404

For Netlify, create a _redirects file in public/:

public/_redirects
/*    /index.html   200

For Apache, create .htaccess:

.htaccess
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

> File Structure Reference

your-template/
├── src/
│   ├── main.jsx              # Entry point
│   ├── App.jsx               # Root component with routes
│   ├── index.css             # Global styles + Tailwind
│   ├── components/           # Reusable components
│   │   ├── Header.jsx
│   │   ├── Footer.jsx
│   │   └── Button.jsx
│   └── pages/                # Page components
│       ├── Home.jsx
│       ├── About.jsx
│       └── Contact.jsx
├── public/                   # Static assets
│   ├── images/
│   └── favicon.ico
├── vite.config.js           # Vite configuration
├── tailwind.config.js       # Tailwind CSS configuration
├── postcss.config.js        # PostCSS configuration
└── package.json             # Dependencies & scripts

> Available Scripts

CommandDescription
npm run devStart development server (port 5173)
npm run buildCreate optimized production build
npm run previewPreview production build locally
npm run lintRun ESLint to check code quality

> Additional Resources

Estimated Setup Time: 3-5 minutes  | Deployment Time: 2-5 minutes

Next Steps: Customize your content, deploy, and launch.