Row-Level Security in Power BI: Implementation & Use Cases
The very first reason why you should implement Row Level Security is to foster trust, a crucial element for any business's success. Next, it reduces data clutter and helps you load...
Kapil Panchal - January 12, 2023
Listening is fun too.
Straighten your back and cherish with coffee - PLAY !
React.js is a prominent solution for creating sophisticated UI interactions that connect with the server in real-time using JavaScript-driven websites. It is capable of competing with top-tier UI frameworks and greatly simplifies the development process.
In this article, we will learn how to create a progressive web application using React.js (PWA). But, before we get started, we'll learn about progressive web apps and why they're so important.
PWA is a dynamic web application that may work independently and offers several benefits such as performance, flexibility in terms of utilizing it with or without an internet connection, platform-specific, and installable.
A progressive web app is an enhanced type of web app that has some of the same capabilities as a native or platform-specific app.
For example, progressive web apps can be installed directly on a user’s home screen and can run in a standalone window. These apps run fast and reliably under poor network conditions and can even function offline.
Think of how your typical mobile user moves through changing environments while using your app. For example, they might start out in a building that has a reliable high-speed network. But, when they walk out to the street, they may lose Wi-Fi and fall back to cellular connectivity.
They might catch a strong 4G or even 5G signal, or, they may hit a low-service dip that only has 3G. How can they stay on your app in all network conditions, even when they have no connectivity at all?
A progressive web app lets you reach your users wherever they are and serve them fast and reliable user experiences in any network environment.
It's necessary to set up your project before you can start coding. Let's begin by making sure you can use React (if you're already comfortable with React code, you can definitely skip this piece!). When using web frameworks like Angular, React, or Vue for development, you must use Node.js, especially if you intend to employ libraries and packages to speed up the process.
The Node Package Manager, also known as "npm," is a widely used tool for using such packages and libraries. You can start building your React application using webpack and install and remove packages using this program, among many other things. For your requirements, you can use npm to build a React application using a PWA template, allowing you to start coding right away. Whenever you begin developing a React project, you can use Facebook's templates by using the npm command "create-react-app."
Let's develop the PWA basic application by executing the following command:
npx create-react-app my-first-pwa-app --template cra-template-pwa
The following is a breakdown of the above command:
After executing this command, your PWA React application should begin to develop. Your command-line interface must offer a constant stream of prompts.
Figure 1 Folder Structure
The folder structure of your program up to this point is shown here. When it comes to PWAs, there are a few files you should be aware of:
service-worker.js:
A service worker is a special type of web worker that intercepts network requests from a web app and controls how these requests are handled. In particular, the service worker can manage the caching of resources and retrieval of these resources from the cache, thereby supporting the offline-first mode that’s crucial for PWAs.
Service workers provide essential support for running a progressive web application. A service worker takes the form of a JavaScript file that runs in a separate, non-blocking thread from the main browser thread.
manifest.json:
In essence, this is a configuration file that lists several customizable properties for progressive web apps. When the application is presented, it can choose the icons, names, and colors to be used.
{ "short_name": "React PWA", "name": "A React Todo PWA", "icons": [ { "src": "favicon.ico", "sizes": "64x64 32x32 24x24 16x16", "type": "image/x-icon" }, { "src": "logo192.png", "type": "image/png", "sizes": "192x192" }, { "src": "logo512.png", "type": "image/png", "sizes": "512x512" } ], "start_url": ".", "display": "standalone", "theme_color": "#F4BD42", "background_color": "#2B2929", }
The functionality of these attributes in the manifest are:
We will link the manifest file to the index.html as
and add the icon that will point to the apple devices home screen as
The index.html markup should look like this:
Firstly, let's create a Counter component. Here, it is located in a components folder and given the name Counter.js.
To simplify the process, copy and paste the following code into the required files. In this example, it is built as a simple page.
By typing "npm start" at the command prompt, you can launch your application to a chosen localhost URL. You can now begin to assess your prior efforts.
Let's try to execute this application using these basic components to make sure it is working.
Enter the command:
npm start
This launches the program at the specified localhost URL. Visit the URL to examine the application once the dev server is active and live on the command prompt. You need to see something like this:
Figure 2 React Counter App
Returning to the index.js file change the following:
You can basically use the app even while it's offline by changing the service worker from unregistered to registered, which is a significant advantage of PWAs.
You can learn more about this here.
Once you've configured the PWA files, you can use the "serve" package to deploy your application to a static server and test it by serving it to localhost.
Now, install the service package, rebuild the application, and deploy the application using serve to ensure that you have it:
npm install serve npm run build serve -s build //if you encounter an error with this command, try 'npx serve -s build'
When you run the serve command, the following message should appear, indicating that your application has been deployed to http://localhost:3000. Also, the URL is automatically copied to your clipboard for convenient pasting in your browser.
Figure 3 Successful Compiling Message
You should see something like this if you type the localhost URL into your browser:
Figure 4 PWA Counter App
Now that the PWA React application is operational, let's open the Developer Tools to check inside (for Google Chrome, entering F12 opens the Dev Tools).
You should be able to see your service worker from index.js running in the Application tab after registering it. On the left side of the tab should be a section for service workers. You can view for http://localhost:3000 from here. You currently have a Service Worker that is active and running from your service-worker.js file.
You can click on Manifest in the section above and doing so should display the pertinent information from your manifest.json files that you mentioned.
Figure 5 Manifest For PWA App
That's it; you've successfully built your first PWA React application! Many PWA features, including installation, offline browsing, and Lighthouse audit testing, can be tested from this point.
PWAs deliver native-like experiences and increased engagement through features such as home screen additions, push notifications, and many others that do not require installation. When built using React.js, these apps have the potential to provide a fantastic user experience with fantastic interaction. React.js is a prominent platform that competes with top-tier UI frameworks and considerably simplifies web app development. This article has walked you through the process of building a progressive web application using React.js. We also learned about the relevance of PWA in the business.
Build Your Agile Team
The very first reason why you should implement Row Level Security is to foster trust, a crucial element for any business's success. Next, it reduces data clutter and helps you load...
The performance of Power BI is significantly influenced by two essential factors: design consistency and the rapid loading of BI elements. This holds true whether you choose Tableau...
Power Automation is no longer an option but a necessity for every firm, be it legal, fintech, aviation, or healthcare. In times of hectic schedules, just imagine there you have an...