[2.0] SkyRoutes : A Simple framework for Progressive Web Apps

Aakash Pandey
The Startup
Published in
4 min readOct 14, 2019
Image of landing page

With the increasing trend of progressive web apps and great support from all major app stores it is clearly visible the web is the future!

But there is a problem, by looking at the term PWA we are simply reminded of this :-

Chrome add to homescreen snackbar

But that’s not all what PWAs have to offer, you can actually create a complete native app experience and publish it on major app stores and the best thing about it is that you’ll have the exact code-base everywhere, the next closest solution to offer this is flutter (more on that some other day)

How can SkyRoutes help if PWAs are already that fancy?

You see, with the common DIY articles on progressive web apps we are just introduced to basic caching and full screen experience. In a real life scene one also needs to maintain the app by delivering updates, handling user events, etc. All this can be too verbose for someone who’s just starting fresh.

SkyRoutes can chop those veggies for you, so you can focus on cooking

Backstory : How it all began Read here

Features :

  1. Complete Asset management
  2. Built in SPA Router
  3. User event handlers ( Network / App state )
  4. Dev friendly (Bonus features )
  5. Natural single file controls

App structure overview

manifest.json with custom skyroutes object definition

manifest.json : We initialize, control and maintain our application through this single file.

Inside the skyroutes object, we can specify our common app assets, which are cached by our service worker on first load, this helps with faster load times and offline support.

SkyRoutes can take care of keeping these assets always fresh(atomic updates)

What about html ?

A bit different index.html

index.html : Holds meta info and app file links. It is just used as a container!

Ps. add a ‘style’ class to all your css links for enabling a cool feature!

app.html for the usual markup

app.html : Holds our regular html markup. But there’s a catch!

Since SkyRoutes is designed for PWAs we have to divide our app into different routes ( sections or views ) as there is a single html file, this helps us to avoid redundant code for multiple html pages.

To create a route just add a class ‘rt’ to the element, for the unique default or initial route use the class ‘irt’, the id attribute of the element acts as its router path

nav method is used for Route navigation, it accepts the path/id of route as an argument. For initial route we use an empty string, i.e. nav(‘ ’)

We can also use anchor tags as an alternative, but that’ll cause hard navigation

Gallery

SPA Router in action
App Init
Atomic updates
Serverless Hot Reload
Force update via SW
Force add to homescreen
Network critical app
Navigation grabbing
Flutter like errors, but these actually help

Future update plans :

  1. Hash path fallback for older browsers (or if SW not initialized )
  2. Fancy router transitions
  3. Some fix for back button nightmare

Check out SkyRoutes

PS: This is still under testing, starter kit will be shared shortly

Feel free to leave your feedback or ideas as a response 😀

Thanks for Reading! 😎

--

--