Skip to content

Address bar showing up when installing as PWA #278

Description

@churichard

Summary

I have the scope set to /app in my next.config.js, and my start_url in my manifest is /app/. However, I'm having an issue where the address bar is showing up in my PWA, even though I have display set to standalone in my manifest.

My manifest:

{
  "name": "...",
  "short_name": "...",
  "icons": [
    {
      "src": "/android-chrome-192x192.png",
      "sizes": "192x192",
      "type": "image/png"
    },
    {
      "src": "/android-chrome-512x512.png",
      "sizes": "512x512",
      "type": "image/png"
    },
    {
      "src": "/maskable-icon.png",
      "sizes": "1024x1024",
      "type": "image/png",
      "purpose": "any maskable"
    }
  ],
  "theme_color": "#FFFFFF",
  "background_color": "#FFFFFF",
  "start_url": "/app/",
  "display": "standalone",
  "orientation": "portrait"
}

My next.config.js properties for next-pwa:

pwa: {
  dest: 'public',
  scope: '/app',
  disable: process.env.NODE_ENV === 'development',
  dynamicStartUrlRedirect: '/login',
  reloadOnOnline: false,
},

Versions

  • next-pwa: 5.3.1
  • next: 11.1.2

How To Reproduce

Steps to reproduce the behavior:

  1. Set up Next.js with next-pwa and the properties above
  2. Go to the app on Android and click the "Add to Home Screen" banner that shows up at the bottom
  3. Once the app is installed, open it up and observe that the address bar shows up at the top

Expected Behaviors

I would expect the address bar to not show up.

Screenshots

Additional Context

I noticed that if I don't set the scope in my next.config.js, then it works fine and there is no address bar. However, this doesn't work for me because I don't want to cache my marketing pages.

According to this Stack Overflow answer, this issue could be occurring because my app is navigating outside of the scope.

I looked at the codebase for next-pwa and saw that a / is being added to the scope:

const _scope = path.posix.join(scope, '/')

So this could be occurring because the the user is starting at /app, but /app is not technically inside of /app/.

Is the / at the end necessary? If not, maybe we could remove it, or at least expose an option to remove it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions