Skip to content

Latest commit

 

History

History
56 lines (35 loc) · 2.68 KB

README.md

File metadata and controls

56 lines (35 loc) · 2.68 KB

PWA

A simple example of a Progressive Web App setup using React.

Installation

To run it locally, clone the repo and make sure you execute these commands in the project directory:

npm install

After that all the project's dependencies will be installed. As PWAs need Service Workers to work and these Service Workers are only enabled in production environment, you are going to have to build the application and serve it with some HTTPS server (another requirement for Service Workers). To do that you can execute the following commands:

// Builds the app
npm run build

// Installs a HTTP server globally
npm install serve -g

// Serves the build through the server
serve -s build

// Creates a tunnel that can be accessed outside your network (and forces the project to be served through HTTPS). PS: In <PORT_TO_BE_TUNNELED> put the port in which the react app is executing, usually 3000.
npx localtunnel --port <PORT_TO_BE_TUNNELED>

Localtunnel will show in the terminal a public link in which you can access your react app. This link can be accessed from anywhere, so you can share the project with other people. PS: Localtunnel is a lib used for prototype purposes, so it has some limitations, if you want to put your app open to public search for alternatives.

FAQ

  • What is a PWA?

The initials means Progressive Web App. They are web applications that offer native mobile features. It became popular alternative to mobile apps, since they are cheaper, easier to setup, super fast, and the development it's like of a website.

  • What is a Service Worker?

It's a script that is executed in the background of a browser. It is used for processing that doesn't need user interaction. In PWAs its commonly used for background data synchronization, push notifications, pre-fetching resources, caching resources, etc. An important thing is that Service Workers needs to be in the production environment and be served in a secure connection (HTTPS) to work.

Useful links