lemmy-ui icon indicating copy to clipboard operation
lemmy-ui copied to clipboard

Add a lemmy protocol handler

Open dessalines opened this issue 8 months ago • 3 comments

There's also protocol handlers.

On your home instance, lemmy-ui (or your favourite app would register itself as a web+lemmy: protocol handler. In JS this looks like navigator.registerProtocolHandler("web+lemmy", "https://lemmy.world/resolve?url=%s", "Lemmy cross-instance link handler")

On firefox, this results in a prompt like this:

image

On chrome like this:

image

Now, all links to web+lemmy:... will go to your home instance (or app on android).

Every lemmy-ui would have a button "Open on my local instance". The button is a href to web+lemmy:https://<post/comment/community/user url>.

Edit: I think there's multiple sparate issues being discussed in this issue. I'm making it worse. Probably would make sense to split it out more or make it more generic

Originally posted by @phiresky in #2987

dessalines avatar Mar 26 '25 12:03 dessalines

Looks like this needs to be done in frontends, by calling registerProtocolHandler(scheme, url)

Nutomic avatar Mar 27 '25 09:03 Nutomic

Safari, Chrome for Android and others don't support it.

Image

https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler#browser_compatibility

matc-pub avatar Mar 27 '25 09:03 matc-pub

EDIT: I guess you register the protocol handler first and then all your links have to use that without hostname or protocol

does web+lemmy:https://retrolemmy.com/whatever work when not registered or only when you have a registered handler? I used inspect element to modify an href into that format but it didn't work (Chrome, Windows)

maybe javascript could do something to detect it but I don't see a method for checking if a protocol handler is registered

Failed to launch 'web+lemmy:https://developer.mozilla.org/' because the scheme does not have a registered handler.

Maybe javascript can catch that exception and open the regular link, but I didn't try putting this in an onclick event

I also didn't try Firefox yet, but this could definitely be something based on which browser is detected

Die4Ever avatar Mar 27 '25 14:03 Die4Ever

This is related to Instance agnostic links which are already implemented in the backend. So its not necessary anymore.

Nutomic avatar Jul 28 '25 12:07 Nutomic