🔥 How to Hide The Address Bar in a PWA

March 16, 2020 • ☕️ 1 min read

Gatsby is a blazing fast static site generator for React. Despite this tagline, Gatsby is much more than that. It is a PWA (Progressive Web App) Framework designed to provide amazing performance out of the box.

Creating a PWA with Gatsby is as easy as enabling one plugin:

js
1// gatsby-config.js
2module.exports = {
3 siteMetadata: {},
4 plugins: [
5 ...
6 // Enables Progressive Web App + Offline functionality
7 `gatsby-plugin-offline`
8 ...
9 ]
10}

There are multiple options that can change the way the UI is displayed, including:

  • Standalone
  • FullScreen
  • Minimal-UI
  • Browser

Let’s have a look at each of these modes, starting with the one that hides the address bar.

FullScreen Display Mode

As the name says, this mode is used for the app to go full screen.

json
1"display": "fullscreen",

Now, the app will use the entire display available on the device. Browsers elements like the back and forward buttons and the address bars are hidden. If you use the PWA in an Android device, then the status bar will also be hidden.

Standalone Display Mode

In stand alone mode, the PWA will feel more like a native app.

json
1"display": "standalone",

It can have its own custom icon so you can open it from the app launcher and the user device will exclude UI elements for controlling the navigation.

Minimal UI

In this mode, the PWA will have a similar look to the standalone application, with the difference that it will implement a minimal set of UI elements for controlling the navigation:

json
1"display": "minimal-ui",

On mobile devices, the PWA will run in its own window which is separated from the browser. However, the elements that are hidden from the display area will vary based on the browser you use. For instance, the address bar is displayed, but only to show the route you are currently; so you cannot type into it.

Browser

The browser mode represents the standard browser experience.

json
1"display": "browser",

Here, the default browser navigation UI elements will be displayed on the screen (e.g. address bar and navigation).

Conclusion

Make sure to try out all these modes on your PWA until you find the one that better represents the experience that you want to transmit to your users.

hot-tipgatsby