This guide shows you how to link from your dApp to another dApp, a website or a social app when your dApp runs inside the MyDoge app.
Link to Another dApp#
Inside MyDoge, link to another dApp with a mydoge://dapp URL, so it opens with its own wallet connection. MyDoge first shows the other dApp’s details screen above yours, and your dApp stays open until the user taps Open, so save any state you need before that. A plain https link would load it inside your dApp’s session (why). Outside MyDoge, use the plain URL. getDappHref() returns the right one when you tell it where the page is running:
"use client"
import { useEffect, useState } from "react"
import { getDappHref, isInMyDogeBrowser } from "@dogeos/dogeos-sdk"
const BUY_URL = "https://swap.example/buy?token=MOON"
export function BuyLink() {
// null until detection finishes, so no plain link can be tapped inside MyDoge first.
const [inMyDoge, setInMyDoge] = useState<boolean | null>(null)
useEffect(() => {
void isInMyDogeBrowser().then(setInMyDoge)
}, [])
const href = inMyDoge === null ? undefined : getDappHref(BUY_URL, { inMyDoge })
return <a href={href}>Buy MOON</a>
}Leave the link without an href until detection finishes. A server-rendered plain link can be tapped inside MyDoge before your page hydrates, which loads the other dApp in your dApp’s session. Outside MyDoge, detection takes up to 500 ms after hydration.
Make sure that:
- The target is a listed dApp. The target URL’s origin exactly matches one of the destination dApp’s listed origins. Subdomains such as
wwwand non-default ports count as different origins. Path, query and fragment are passed through unchanged. - Users have MyDoge 3.1.1 (build 652) or later. Earlier builds ignore a tapped
mydoge://link, and your page can’t tell them apart from 652. - The link follows the rules for links that leave your dApp.
MyDoge ignores a second dApp link within two seconds. See getDappHref and getMyDogeDappLink for the full reference.
Link to Websites and Social Apps#
How MyDoge handles a link depends on where it points:
| Link to | What happens |
|---|---|
Another dApp, through mydoge://dapp | Opens that dApp with its own wallet connection |
X (x.com, twitter.com) | Opens in the X app, or in the system browser when X isn’t installed |
Any other https website | Loads inside your dApp’s view |
An app link, such as twitter:// or mailto: | Isn’t opened |
So link with ordinary https URLs. For a share button, use the service’s web share URL, such as X’s intent URL, and build it before the user taps:
<a href="https://x.com/intent/post?text=I%20scored%201234&url=https%3A%2F%2Fgame.example">Share on X</a>Don’t rely on navigator.share: Android’s in-app browser doesn’t provide it.
X’s sign-in pages are the exception to the X rule: they stay inside MyDoge, so “Sign in with X” can return to your dApp; see Keep Your Own Sign-In Working.
Rules for Links That Leave Your dApp#
MyDoge opens links to other dApps and to apps outside MyDoge only when the user taps them:
- Set the
hrefbefore the user taps. A plain link works on every build. Atarget="_blank"link orwindow.open()called synchronously in the tap handler also works on MyDoge 3.1.1 and later. - Don’t set
location.href. It doesn’t work on iOS. - Don’t open the link after an
await, a timer or a network call. The tap no longer counts, so MyDoge may block it. - Keep the link in the top-level page. Links inside an iframe are ignored on iOS and may be ignored on Android.