Git Product home page Git Product logo

sofiane-abou-abderrahim / react-deployment Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 492 KB

๐Ÿš€ React Deployment is a guide for deploying React apps from development to production. It covers testing, optimizing, building & uploading your app to Firebase. It also ensures smooth client-side routing with React Router and performance optimization through lazy loading. Explore the code to master the deployment process & avoid common pitfalls.

Home Page: https://react-deployment-demo-1716b.web.app

HTML 32.00% JavaScript 53.71% CSS 14.29%
deployment javascript lazy-loading optimization react react-router reactjs testing client-side-routing single-page-app server-side-routing firebase

react-deployment's Introduction

Deploying React Apps

From Development To Production

  • Deployment Steps & Pitfalls
    1. Test Code: Manually & with automated tests
    2. Optimize Code: Optimize user experience & performance
      1. Lazy Loading: Load code only when it's needed
      2. Having to load all the code initially will slow down that initial page load
    3. Build App: Run build process to parse, transform & optimize code
    4. Upload App: Upload production code to hosting server
    5. Configure Server: Ensure app is served securely & as intended
  • Server-side Routing vs Client-side Routing

Steps

0. Project Setup

  1. run npm install
  2. run npm start
  3. create a README.md file
  4. create a .gitignore file

1. Adding Lazy Loading

  1. in App.js, in order to load the BlogPage lazily, remove the import of the BlogPage & the PostPage
  2. load the loaderlazily by using the import() function
  3. load the BlogPage & PostPage components lazily
  4. use the lazy() fonction imported from react
  5. wrap the <BlogPage> & <PostPage> components with the <Suspense> component imported from react

2. Building the Code For Production

  1. in the terminal, execute npm run build
  2. a build folder is created & ready to be rendered

3. Deployment Example

  1. in Firebase Hosting, create a new project named react-deployment-demo for example
  2. in your terminal, run
    1. npm install -g firebase-tools
    2. firebase login
    3. firebase init
    4. firebase deploy

react-deployment's People

Contributors

sofiane-abou-abderrahim avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.