Firebase Dynamic Links
Create a short Firebase Dynamic Link from your server.
Create a short link
Turn a deep link into a short Firebase Dynamic Link from your server. Resolves to a FirebaseDynamicLinkResult with dynamicLink, previewLink, and the raw response. Import from @bdk/native/server/firebase-dynamic-links; server-only.
Deprecated — Firebase Dynamic Links has been sunset by Google, so this helper no longer produces working links. For new work, use @bdk/native/server/branch (createBranchLink) or @bdk/native/server/chottulink.
Set inputs from the environment
Each required value can be passed inline or read from an environment variable. Only deepLinkUrl has no env fallback — always pass it.
firebaseWebApiKey→BDK_FIREBASE_WEB_API_KEY,FIREBASE_WEB_API_KEY,FIREBASE_DYNAMIC_LINKS_WEB_API_KEYdomainUriPrefix→BDK_FIREBASE_DYNAMIC_LINK_DOMAIN_URI_PREFIX,FIREBASE_DYNAMIC_LINK_DOMAIN_URI_PREFIXiosBundleId→BDK_IOS_BUNDLE_ID,IOS_BUNDLE_IDiosAppStoreId→BDK_IOS_APPSTORE_ID,IOS_APPSTORE_ID,IOS_APP_STORE_IDandroidPackageName→BDK_ANDROID_BUNDLE_ID,ANDROID_BUNDLE_ID,ANDROID_PACKAGE_NAME
A domainUriPrefix with no scheme gets https:// prepended.
A missing required value (in both input and environment) throws a BdkError with code BDK_VALIDATION_ERROR before any network request.
Read the result
The promise resolves to a FirebaseDynamicLinkResult. Check dynamicLink or errorMessage before using the link.
dynamicLink: string | null— the short link, ornullon failure.previewLink: string | null— the preview link, ornullif absent.errorMessage: string | null—nullon success, otherwise the API error.raw: unknown— the full JSON response.
A failed API call does not throw — it returns dynamicLink: null with errorMessage set, so always branch on one of those.
Add query params and redirect options
Shape the URL and redirect behavior of the generated link.
urlParamsappends query parameters todeepLinkUrl;null/undefinedvalues are dropped.suffixOptionsets the path length:"SHORT"(case-insensitive) for a short suffix, otherwise"UNGUESSABLE".enableForcedRedirect: trueskips the app preview page.
Set platform fallbacks
Control where users without the app installed are sent with iosFallback and androidFallback (both FirebaseDynamicLinkFallback). The type field (case- and spacing-insensitive) picks the behavior:
"app-store-page"/"play-store-page"— sends to the store; the iOS / Android default. Nourlneeded."same-url"— redirects todeepLinkUrl."fallback-url"— redirects to a customurl(required), with optionalurlParams.
Use iosIpadFallbackUrl for a dedicated iPad fallback.
Use a custom endpoint or fetch
Point at a different endpoint or inject a fetch for testing or proxying. Set baseUrl (default https://firebasedynamiclinks.googleapis.com/v1) and pass a fetch (FetchLike) matching the global fetch signature.