Skip to content

natnael-eyuel-dev/react-boilerplate

Repository files navigation

React Boilerplate App

This is a comprehensive React boilerplate designed to give you a robust starting point for your web projects. It includes a structured setup with modern React practices, Tailwind CSS integration, state management with React Context, and pre-configured tools for code quality.

Features

  • React 18+: Latest React features and conventions.
  • Tailwind CSS: A utility-first CSS framework pre-configured for rapid UI development. Includes tailwind.config.js and postcss.config.js.
  • Component Structure: An example src/components folder to encourage modularity.
  • React Context API: A src/context/ThemeContext.js example for global state management (e.g., theme toggling).
  • Internal Navigation: Simple page routing using React state and conditional rendering (no react-router-dom to keep it lightweight and adhere to specific guidelines).
  • ESLint: Configured with eslint-plugin-react and eslint-config-prettier for code linting.
  • Prettier: Integrated with .prettierrc.js for consistent code formatting.
  • Responsive Design: Built with Tailwind CSS to ensure adaptability across various devices.
  • Error Handling: Basic onError for image fallbacks.
  • .gitignore: Standard Git ignore file for Node.js/React projects.

Getting Started

Follow these steps to get your project up and running using this boilerplate from GitHub:

Clone and Re-initialize Git

This method involves cloning the boilerplate and then removing its Git history to start fresh for your new project.

  1. Clone the Boilerplate: Clone this boilerplate repository to your local machine:
    git clone https://github.com/YOUR_USERNAME/BOILERPLATE_REPO_NAME.git YOUR_NEW_PROJECT_NAME
    cd YOUR_NEW_PROJECT_NAME
    (Replace YOUR_USERNAME/BOILERPLATE_REPO_NAME with the actual path to this boilerplate on GitHub, and YOUR_NEW_PROJECT_NAME with your desired project folder name.)
  2. Remove Existing Git History: Delete the .git directory to remove the boilerplate's history:
    rm -rf .git  # On Windows, use `rmdir /s /q .git`
  3. Initialize a New Git Repository: Initialize a fresh Git repository for your new project:
    git init
  4. Add Files and Initial Commit: Add all files to the new repository and make your first commit:
    git add .
    git commit -m "feat: Initial commit for new React project from boilerplate"
  5. Create New GitHub Repository: Go to GitHub and create a new, empty repository (do NOT initialize with a README, .gitignore, or license).
  6. Connect Local to Remote: Add your new GitHub repository as the remote origin:
    git remote add origin https://github.com/YOUR_USERNAME/YOUR_NEW_REPO_NAME.git
  7. Push to GitHub: Push your local project to the new GitHub repository:
    git push -u origin main
    # Or if your default branch is `master`:
    # git push -u origin master
  8. Install Dependencies: In your project directory, open your terminal and run:
    npm install
    # or
    yarn install
  9. Start the Development Server: Once dependencies are installed, you can start the development server:
    npm start
    # or
    yarn start
    This will open your application in your default web browser at http://localhost:3000 (or another available port).

Project Structure

├── public/                     # Static assets and the main HTML file
│   └── index.html              # The entry point for the browser
├── src/                        # React source code
│   ├── components/             # Reusable UI components
│   │   └── Card.js             # Example Card component
│   ├── context/                # React Context providers for global state
│   │   └── ThemeContext.js     # Example Theme Context
│   ├── App.js                  # Main application component with internal navigation
│   └── index.js                # React app entry point, mounts App component
├── .gitignore                  # Files and directories ignored by Git
├── package.json                # Project metadata, scripts, and dependencies
├── tailwind.config.js          # Tailwind CSS configuration
├── postcss.config.js           # PostCSS configuration for Tailwind
├── .eslintrc.js                # ESLint configuration for code quality
├── .prettierrc.js              # Prettier configuration for code formatting
└── README.md                   # This documentation file

Customization

  • src/App.js: This is where your main application logic and top-level components will reside. You can extend the internal navigation or replace it with a routing library if needed for more complex routing (though this boilerplate uses a state-based approach).
  • src/components/: Create new subdirectories and files here for each of your reusable UI components.
  • src/context/: Add more contexts here for different pieces of global state your application might need (e.g., AuthContext, DataContext).
  • Tailwind CSS: Modify tailwind.config.js to extend Tailwind's default theme, add custom utilities, or configure plugins.
  • ESLint/Prettier: Adjust .eslintrc.js and .prettierrc.js to match your team's specific coding style and rules.

Available Scripts

In the project directory, you can run:

  • npm start: Runs the app in development mode.
  • npm run build: Builds the app for production to the build folder. It correctly bundles React in production mode and optimizes the build for the best performance.
  • npm test: Launches the test runner in the interactive watch mode.
  • npm run eject: Caution: This command removes the single build dependency from your project. If you do this, you can't go back! It copies all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc.) right into your project so you have full control over them.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published