Migrate from Firebase: swap the SDK
After this page, you will have an app that gets Strait links in the same place it got Dynamic Links, with one callback for every open, including the first open after an install.
On this page 8
- Time
- About 30 minutes per app
- You need
- The plan from Migrate from Firebase, your app's code
- Works on
- Android, iPhone, React Native, Flutter
Only do the step for your kind of app (Android, React Native, Flutter, iOS, Unity or web), then step 6 if your app made links itself. Skip the rest.
Dynamic Links gave you two calls: one for the link that opened the app, and a listener for links while it runs. Strait has one: you call start() once and get every link in onLink. Its kind is direct (the app was installed) or deferred (the link was tapped before the install).
| Dynamic Links call | Strait SDK |
|---|---|
Android Firebase.dynamicLinks.getDynamicLink(intent) |
links.start(intent?.dataString) in onCreate, links.handleUrl(...) in onNewIntent, then links.onLink { e -> } |
React Native dynamicLinks().getInitialLink() + dynamicLinks().onLink(fn) |
links.start() + links.onLink(fn) |
Flutter FirebaseDynamicLinks.instance.getInitialLink() + .onLink.listen |
links.start(initialUrl:, urls:, lifecycle:) + links.onLink.listen |
iOS DynamicLinks.dynamicLinks().handleUniversalLink(url) |
links.handle(userActivity:) and links.handle(url:) |
pendingDynamicLinkData.link (a full URL) |
e.path and e.params (already split), or e.url |
FirebaseDynamicLinks.getInstance().createDynamicLink() in the app |
A call to your own server, which uses POST /v1/links (example) |
1. Android (Kotlin)
Do this: remove com.google.firebase:firebase-dynamic-links from app/build.gradle.kts and add the Strait SDK (Install & set up). Then swap the red lines for the green ones:
- Firebase.dynamicLinks.getDynamicLink(intent).addOnSuccessListener { data ->
- data?.link?.let { openDeepLink(it.path, it.queryParameterNames.associateWith { k -> it.getQueryParameter(k)!! }) }
- }
+ links.onLink { e -> runOnUiThread { if (e.matched) openDeepLink(e.path, e.params) } }
+ if (savedInstanceState == null) links.start(intent?.dataString)override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
intent.dataString?.let(links::handleUrl) // replaces getDynamicLink(intent) for a running app
}In the manifest, add an intent filter for hilltop.strait.link (keep the yourapp.page.link one if people who have your app should still open it from old links: how), and add your custom scheme filter if you didn't have one (manifest).
You should see: adb shell am start -W -a android.intent.action.VIEW -d "https://hilltop.strait.link/summer" opens the same screen the old Dynamic Link did.
2. React Native
Do this: in your app's folder, swap the packages, then swap the red lines for the green ones.
npm uninstall @react-native-firebase/dynamic-links
npm install @straitlink/react-native@0.11.6 @react-native-async-storage/async-storage react-native-play-install-referrer- import dynamicLinks from '@react-native-firebase/dynamic-links';
- dynamicLinks().getInitialLink().then((link) => link && handle(link.url));
- const unsubscribe = dynamicLinks().onLink((link) => handle(link.url));
+ import { links } from './links'; // createStrait({ publishableKey, endpoint, storage, installReferrer }); links.start();
+ const unsubscribe = links.onLink((e) => e.matched && e.path && openPath(e.path, e.params));links.ts is on Install & set up. openPath maps a path to a screen (Receive links). Expo apps: Expo (Expo Router).
You should see: a tap on https://hilltop.strait.link/summer opens the screen, and so does the first open after installing from Google Play.
3. Flutter
Do this: swap the packages, add strait_sdk to pubspec.yaml, then swap the red lines for the green ones.
flutter pub remove firebase_dynamic_links
flutter pub add app_links shared_preferences play_install_referrer flutter_timezonedependencies:
strait_sdk: ^0.10.9links.dart is on Install & set up.
- final initial = await FirebaseDynamicLinks.instance.getInitialLink();
- if (initial != null) route(initial.link);
- FirebaseDynamicLinks.instance.onLink.listen((data) => route(data.link));
+ await startLinks(); // links.dart: StraitLinks(...) + links.start(...)
+ links.onLink.listen((e) { if (e.matched && e.path != null) routePath(e.path!, e.params ?? {}); });You should see: the Flutter console logs Strait link: direct app_link true /product/42 when you tap https://hilltop.strait.link/summer.
4. iOS
Do this: replace the Firebase package with StraitSDK from https://github.com/strait-link/strait-sdk-swift, and add applinks:hilltop.strait.link to Associated Domains (keep applinks:yourapp.page.link for old links: how):
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
- guard let url = userActivity.webpageURL else { return }
- DynamicLinks.dynamicLinks().handleUniversalLink(url) { link, _ in route(link?.url) }
+ links.handle(userActivity: userActivity) // links.onLink { event in … } routes it
}The full setup, including the launch URL and SwiftUI, is on the iOS page. Universal Links are tested on a real iPhone; install matching after an App Store install is opt-in.
You should see: the app builds without FirebaseDynamicLinks, and links.onLink fires for a Universal Link on your domain.
5. Unity and the web
Do this (Unity): Firebase's Unity plugin raised DynamicLinks.DynamicLinkReceived. Strait's plain C# library raises OnLink, and Unity's own Application.deepLinkActivated feeds it links while the game runs:
- DynamicLinks.DynamicLinkReceived += (sender, args) => Route(args.ReceivedDynamicLink.Url);
+ Client.OnLink += e => { if (e.Matched) Route(e.Path, e.Params); };
+ Application.deepLinkActivated += url => _ = Client.HandleUrl(url);
+ await Client.Start(Application.absoluteURL); // launch link + deferred checkThe full LinksBehaviour is on the Unity page. Its engine glue hasn't been run in the Unity editor yet, so test it on a device before you ship.
Web: nothing to do for most sites. Dynamic Links sent desktop visitors to the ofl URL. Strait does the same with desktopUrl, or the destination itself, with no code. If your web app wants the link a visitor tapped on their phone before switching to the browser, the web SDK asks once per browser.
You should see: a Unity build logs the link's path on a device, and a desktop browser opening https://hilltop.strait.link/summer lands on your website.
6. Replace in-app link creation
Do this: if your app made links with the Dynamic Links builder, move that to your server. Making links needs the secret key, and the secret key must never be in an app.
- const link = await dynamicLinks().buildShortLink({ link: productUrl, domainUriPrefix: 'https://yourapp.page.link' });
+ const { url: link } = await (await fetch('https://api.yourapp.com/share', { method: 'POST', body: JSON.stringify({ productId }) })).json();You should see: your share sheet offers https://hilltop.strait.link/… links. The server side is on Create links in the app.
Common errors
- Both SDKs handle the same link. Remove the Dynamic Links dependency completely; leftover listeners can swallow the intent.
- The app still opens old
page.linkURLs in the browser. Expected when the build dropped the page.link domain or Google stopped serving its app-link files: some still do a plain redirect to the old fallback. Keep the domain to open the app for people who have it (how), and recreate the links on your domain (Import and cut over). - Routing breaks on the full URL. Strait gives you
e.pathalready split from the host. Route on the path.
Next steps
- Import and cut over: recreate your links and switch your backend.
- Test: check direct and deferred links on a real phone.