I will develop a web app in react js
I will develop a web app in react js
Developing a web app in React JS is a great way to build interactive and dynamic user interfaces. React is a JavaScript library that is used for building user interfaces. It is maintained by Facebook and a community of individual developers and companies.
Get develop a web app in react js
To get started with React, you can use tools like Create React App1 which lets you focus on code rather than build tools. You can also learn how to create a front-end app with React on Codecademy2.
If you want to develop a Progressive Web App using ReactJS, you can follow the step-by-step implementation on how to do so on GeeksForGeeks3.
Progressive React Applications respond very fast to user actions. They load fast and are engaging just like a mobile app. They can access Mobile device features, leverage the Operating System and have a very high reach. It enables Installability, Background Syncing, Caching and Offline Support and other features like Push Notifications. With React, we can very easily enhance web apps progressively to look and feel like native mobile applications.
Now let’s see step-by-step implementation on how to develop a Progressive Web Application using React.
Step 1: With ReactJS, it is even easier to create a Progressive Web App or even convert an existing React project into one. In the terminal of your text editor, enter the following command. CRA creates a boilerplate for Progressive Web App that you can easily modify according to your needs.
npx create-react-app react-pwa –template cra-template-pwa
cd react-pwa
This command creates a new React Application named react-pwa and navigates to the directory of your app. You can further modify your manifest.json file and other files like the logo to customize the app and make it your own.
Step 2: Let’s implement the functionalities of a PWA and add more features to our App. In the terminal of your text editor enter the following command to install some third-party and npm packages.
npm install –save web-push react-router-dom bootstrap react-bootstrap
Project Structure: Add worker.js and feed.js in your public folder and a components folder inside your src folder, so that it looks like this.
Project Structure
Step 3: Register a Service Worker – A Service Worker is a special kind of script file that works between the browser and the network. It helps us to perform unique functionalities and registers itself whenever a page is loaded. To register a new service worker in your React App, in the worker.js file in your public folder (public/worker.js), add the following code.
var STATIC_CACHE_NAME = "gfg-pwa";
var DYNAMIC_CACHE_NAME = "dynamic-gfg-pwa";
// Add Routes and pages using React Browser Router
var urlsToCache = ["/", "/search", "/aboutus", "/profile"];
// Install a service worker
self.addEventListener("install", (event) => {
// Perform install steps
event.waitUntil(
caches.open(STATIC_CACHE_NAME).then(function (cache) {
console.log("Opened cache");
return cache.addAll(urlsToCache);
})
);
});
// Cache and return requests
self.addEventListener("fetch", (event) => {
event.respondWith(
caches.match(event.request).then((cacheRes) => {
// If the file is not present in STATIC_CACHE,
// it will be searched in DYNAMIC_CACHE
return (
cacheRes ||
fetch(event.request).then((fetchRes) => {
return caches.open(DYNAMIC_CACHE_NAME).then((cache) => {
cache.put(event.request.url, fetchRes.clone());
return fetchRes;
});
})
);
})
);
});
// Update a service worker
self.addEventListener("activate", (event) => {
var cacheWhitelist = ["gfg-pwa"];
event.waitUntil(
caches.keys().then((cacheNames) => {
return Promise.all(
cacheNames.map((cacheName) => {
if (cacheWhitelist.indexOf(cacheName) === -1) {
return caches.delete(cacheName);
}
})
);
})
);
});
Step 4: Some old browsers may not support service workers. However, most modern browsers like Google Chrome have in-built support for service workers. In case of the absence of support, the app will run like a normal web application. To make sure that we don’t run into an error or the app doesn’t crash, we need to check whether the support status of service workers in the browser of the client. To do so, update your index.html file in the public folder (public/index.html) with the following code.
One Page Website : $4,000
Simple one page application with basic features.
3 Page Website : $7,000
Dynamic Web Application with up to 3 Pages.
Large Website : $10,000
Customized web application with up to 7 pages, perfect for businesses [Prices are not final]