DEV Community

loading...

Discussion on: How to handle outbound links in desktop PWA?

Collapse
niorad profile image
Antonio Radovcic • Edited

Does this maybe help?
developer.mozilla.org/en-US/docs/W...

Defines the navigation scope of this website's context. This restricts what web pages can be viewed while the manifest is applied. If the user navigates outside the scope, it returns to a normal web page inside a browser tab/window.

Collapse
ben profile image
Ben Halpern Author

I believe that is more for defining the scope of the PWA guidelines within the application. Basically instructing the browser not to run service workers etc. outside of the defined scope.

And if it means otherwise, I'm not sure how to get it to work. πŸ˜„

Since asking this question, I'm starting to think that the expected behavior really should be open in the browser. That way you can keep your DEV context, especially in the case of /connect etc.

Collapse
niorad profile image
Antonio Radovcic

But isn't this exactly what you asked?

"If the user navigates outside the scope, it returns to a normal web page inside a browser tab/window."

So you define the scope in the manifest.json and shouldn't even need to add target="_blank" to links.

Thread Thread
terabytetiger profile image
Tyler V. (he/him) • Edited

Based on the information on developers.google.com/web/fundamen... it appears that you do need to add target="_blank"

"Caution: If the user clicks a link in your app that navigates outside of the scope, the link will open and render within the existing the PWA window. If you want the link to open in a browser tab, you must add target="_blank" to the <a> tag. On Android, links with target='_blank' will open in a Chrome Custom Tab."

I do see where the confusion came from on the MDN docs. Initially I read it the same way you did.

Thread Thread
ben profile image
Ben Halpern Author

Hmmm perhaps, but implementations may vary. It seems like it still opens another browser page within the app or something. I think it's possible that this detail is not part of the spec. In fact, I think iOS had a the "back to browser" behavior by default and then switch to "in-app browser".

Thread Thread
ben profile image
Ben Halpern Author

@ Tyler, awesome. That is the confirmation I was looking for and hadn't found. This makes it pretty clear what the current behavior is and that it is the expected behavior going forward.