<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>JavaScript on Luiz Bon</title>
    <link>https://luizbon.com/tags/javascript/</link>
    <description>Recent content in JavaScript on Luiz Bon</description>
    <generator>Hugo -- 0.165.0</generator>
    <language>en-AU</language>
    <copyright>Luiz Bon</copyright>
    <lastBuildDate>Sun, 30 Aug 2026 18:50:15 +1000</lastBuildDate>
    <atom:link href="https://luizbon.com/tags/javascript/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>The poor man&#39;s Progressive Web App</title>
      <link>https://luizbon.com/blog/the-poor-mans-progressive-web-app/</link>
      <pubDate>Tue, 31 Jul 2018 19:41:37 +1000</pubDate>
      <guid>https://luizbon.com/blog/the-poor-mans-progressive-web-app/</guid>
      <description>Turning a spreadsheet request from my father into an offline-capable Progressive Web App with no framework and no build step.</description>
      <content:encoded><![CDATA[<h2 id="a-bit-of-context">A bit of context</h2>
<p><a href="#solution"><em>I don&rsquo;t care about the context, show me the solution!</em></a></p>
<p>Last week my father sent me a message asking if I could build an electronic spreadsheet of the following image.</p>
<p><img alt="plan" loading="lazy" src="/img/poor-mans-pwa-1.jpeg"></p>
<p>Looking at the image I promptly reply with &ldquo;Can&rsquo;t you use Excel for this?&rdquo;</p>
<p>Then when I got home I opened my Excel and started to create a simple plan with the data from the image and that&rsquo;s when I saw the notes.</p>
<p><img alt="instructions" loading="lazy" src="/img/poor-mans-pwa-2.jpeg"></p>
<p>This note says &ldquo;Days = Difference between previous and actual date&rdquo;. This was the moment when my Excel skills failed me!
I tried to create a form input, but my research led me to some Visual Basic code and good old visual designer which I don&rsquo;t want to play with it anymore.
So I stopped and put some thinking on the issue.</p>
<ul>
<li>&ldquo;What are my options?&rdquo;</li>
<li>&ldquo;What do I know?&rdquo;</li>
<li>&ldquo;This thing need to work on an offline environment&rdquo; - There&rsquo;s no internet where he use this</li>
</ul>
<p>Building a desktop app means I&rsquo;ll need to create a setup, send to him, control the installation and updates. So is not a good option.
A web page seems simpler to solve the deployment, I&rsquo;m currently working with React, so no learning curve.</p>
<p>Based on this I though about doing an PWA app.</p>
<p>According to <a href="https://en.wikipedia.org/wiki/Progressive_Web_Apps">Wikipedia</a> this is a list of things your app should tick to be called as PWA.</p>
<ul>
<li><input disabled="" type="checkbox"> Progressive - Work for every user, regardless of browser choice because they’re built with progressive enhancement as a core tenet.</li>
<li><input disabled="" type="checkbox"> Responsive - Fit any form factor: desktop, mobile, tablet, or forms yet to emerge.</li>
<li><input disabled="" type="checkbox"> Connectivity independent - Service workers allow work offline, or on low quality networks.</li>
<li><input disabled="" type="checkbox"> App-like - Feel like an app to the user with app-style interactions and navigation.</li>
<li><input disabled="" type="checkbox"> Fresh - Always up-to-date thanks to the service worker update process.</li>
<li><input disabled="" type="checkbox"> Safe - Served via HTTPS to prevent snooping and ensure content hasn’t been tampered with.</li>
<li><input disabled="" type="checkbox"> Discoverable - Are identifiable as “applications” thanks to W3C manifests and service worker registration scope allowing search engines to find them.</li>
<li><input disabled="" type="checkbox"> Re-engageable - Make re-engagement easy through features like push notifications.</li>
<li><input disabled="" type="checkbox"> Installable - Allow users to “keep” apps they find most useful on their home screen without the hassle of an app store.</li>
<li><input disabled="" type="checkbox"> Linkable - Easily shared via a URL and do not require complex installation.</li>
</ul>
<p><a id="solution"></a>With that in mind, let&rsquo;s go to my solution.</p>
<h2 id="1-the-app">1. The App</h2>
<p>To create the app I used the <a href="https://github.com/facebook/create-react-app">Create React App</a> project from Facebook. The output is a basic app with a service worker in place.
So with a simple command I can check some items from the PWA list.</p>
<ul>
<li><input checked="" disabled="" type="checkbox"> Connectivity independent</li>
<li><input checked="" disabled="" type="checkbox"> Fresh</li>
</ul>
<p>This is really nice, but still have some checkboxes to tick.</p>
<h2 id="2-bootstrap">2. Bootstrap</h2>
<p>The app looks nice but it does nothing. Knowing I&rsquo;ll need to create a simple form for data input and a table to show the data, I&rsquo;ve pulled the <a href="http://getbootstrap.com/">Bootstrap 4</a> package and changed the inport from index.html.</p>
<p>And now I can tick one more item.</p>
<ul>
<li><input checked="" disabled="" type="checkbox"> Connectivity independent</li>
<li><input checked="" disabled="" type="checkbox"> Fresh</li>
<li><input checked="" disabled="" type="checkbox"> Responsive</li>
</ul>
<p>That&rsquo;s really nice, I have an app with 3 checkboxes ticked, but what about the functionality? It&rsquo;s time to write some code.</p>
<h2 id="3-react-app">3. React App</h2>
<p>I&rsquo;m not going into much detail here, it&rsquo;s not the intention of the post.</p>
<p>The app consists in a form with three fields pushing into an array and a table with the array contents.</p>
<p>All work fine, but what about persistence? I need to save this data somewhere.</p>
<h2 id="4-firebase">4. Firebase</h2>
<p>After a quick research I&rsquo;ve choosed <a href="https://firebase.google.com/">Firebase</a> to persist my data. It has a service called <a href="https://firebase.google.com/products/realtime-database/">Realtime Database</a> where I can save documents.
It&rsquo;s Javascript SDK has support for offline access and syncronization, so I don&rsquo;t lose my <strong>Connectivity independent</strong> tick.</p>
<p>The next challenge is to integrate Firebase SDK to React, that&rsquo;s when come in handy a simple package called <a href="https://github.com/tylermcginnis/re-base">Re-Base</a>, it&rsquo;s integration is very easy and I only needed to write a few lines of code to have everything in place.</p>
<p>After that integration I could say the app was ready. It was saving the data online and offline. Most importantly was the syncronization happening when connection was restablished.
Because the app have a service worker registered, I don&rsquo;t need to open the app to syncronize, it just works.</p>
<p>With the data being saved online, now was time to secure the data.</p>
<h2 id="5-authentication">5. Authentication</h2>
<p>To solve the Autentication issue Firebase came in handy again. It&rsquo;s SDK has auth integration with <a href="https://firebase.google.com/products/auth/">Firebase Authentication</a>, so I only needed to build a simple account creatiion form and a login page.
After that I configured my database security and it&rsquo;s all in place, each user has access only to their data.</p>
<p>To have another checkbox ticked I need to solve the hosting.</p>
<h2 id="6-cicd">6. CI/CD</h2>
<p>To deploy my code as easly as possible I choosed <a href="https://www.netlify.com/">Netlify</a> as it can integrate with a Git repository and do the deployment.
When configuring the app Netlify could identify it was a Create React App application and suggested me the build command. So it was a next&gt;next&gt;finish experience to have my site up and running on my custom domain with a <a href="https://letsencrypt.org/">Let&rsquo;s Encrypt</a> certificate.</p>
<p>After that I was able to tick on last checkbox</p>
<ul>
<li><input checked="" disabled="" type="checkbox"> Connectivity independent</li>
<li><input checked="" disabled="" type="checkbox"> Fresh</li>
<li><input checked="" disabled="" type="checkbox"> Responsive</li>
<li><input checked="" disabled="" type="checkbox"> Linkable</li>
<li><input checked="" disabled="" type="checkbox"> Safe</li>
</ul>
<h2 id="the-result">The Result</h2>
<p>At the end I spend less than a full day of work of my free time build a fully function app hosted on a HTTPS address with online database and offline capabilities.</p>
<p>If you&rsquo;re curious, below are a couple of screen shots. The source code can be found on <a href="https://github.com/luizbon/pesagem-ventania">Github</a>.</p>
<p><img alt="desktop view" loading="lazy" src="/img/poor-mans-pwa-3.jpeg">
<img alt="mobile view" loading="lazy" src="/img/poor-mans-pwa-4.jpeg"></p>
]]></content:encoded>
    </item>
  </channel>
</rss>
