magic-deeplink
Skill3 starsChanged 17 days agoMITView on GitHub
Route Universal Links, App Links and tapped pushes to Magic routes with the magic_deeplink handler chain.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- anilcancakir/aiword for word, first seen Nov 16, 2026
Other versions1 project uses a version of this.
Word for word · 1
- anilcancakir/ai★ 3100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository19 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- crumbsSkill
- dowelSkill
- flutter-reviewSkill
- magic-analyticsSkill
- magic-deviceSkill
- magic-devtoolsSkill
- magic-encryptionSkill
- magic-frameworkSkill
- magic-local-storageSkill
- magic-notificationsSkill
- magic-paymentsSkill
- magic-pickerSkill
- magic-sentrySkill
- magic-social-authSkill
- magic-socketSkill
- magic-starterSkill
- tapirSkill
- wind-uiSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 27
Put <meta-data android:name="flutter_deeplinking_enabled" android:value="false" /> inside <activity> by hand.
- Very specific: line 32
Do not look for a Deeplink facade.
- Very specific: line 48
Do not route getInitialLink() as well as the provider's stream.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
magic_deeplink
Deep links for a Magic app. DeeplinkServiceProvider wires app_links into DeeplinkManager, which offers each incoming Uri to its handlers in registration order; the first whose canHandle is true handles it. RouteDeeplinkHandler maps a path onto a route with MagicRoute.to. A tapped push from magic_notifications enters the same chain. The deeplink:install, deeplink:generate and deeplink:doctor commands scaffold the config, write the apple-app-site-association and assetlinks.json files and check the install.
This skill covers magic_deeplink only. The Magic framework itself (container, providers, MagicRoute, Config, Log, events) is the magic-framework skill, and the push side is magic_notifications.
Install
flutter pub add magic_deeplink
dart run magic:dowel plugin:install magic_deeplink
dart run magic:dowel deeplink:doctorRequires Dart >=3.13, Flutter >=3.47 and magic ^1.0.0. The installer publishes lib/config/deeplink.dart, adds DeeplinkServiceProvider to lib/config/app.dart, adds the deeplinkConfig factory to lib/main.dart and sets FlutterDeepLinkingEnabled to false in ios/Runner/Info.plist. It registers no handler and does not touch the Android manifest. Import only the barrel: package:magic_deeplink/magic_deeplink.dart.
Setup rules
- Finish the native setup before debugging code. iOS needs the Associated Domains capability with
applinks:<domain>; Android needs anautoVerifyintent filter with a<data>element for bothhttpandhttps; both need their association file served fromhttps://<domain>/.well-known/. Every miss ends the same way, a link that opens the browser with no exception and no log, so rundart run magic:dowel deeplink:doctorfirst. - Put
<meta-data android:name="flutter_deeplinking_enabled" android:value="false" />inside<activity>by hand. The installer cannot place it there, and in<application>Flutter never reads it. Flutter's own deep link handler otherwise takes the link before the chain sees it. deeplink.enabledabsent means on; only an explicitfalsewires nothing, the push bridge included.deeplink.drivermust be'app_links', the only value that creates a driver; another value wires no driver, though the push bridge still runs.deeplink.pathsis written into thecomponentsof the AASA file and filters nothing at runtime. Which paths the app routes is decided by the handler you register.- A
'scheme'key inlib/config/deeplink.dartis read by nothing. Delete it. generateanddoctorreadlib/config/deeplink.dartas text. Keepdomain,team_id,bundle_id,package_name,sha256_fingerprintsandpathsas single-quoted literals, not double-quoted strings or values built from a variable.- Do not look for a
Deeplinkfacade. The entry point isDeeplinkManager(), also bound as'deeplinks'in the container.
Handler rules
- Register your own handler in a provider's
boot():DeeplinkServiceProviderregisters none, and a link with no handler makeshandleUrianswerfalsewith no error. Several handlers are normal;forgetHandlers()clears all of them and there is no way to remove one. - Register specific handlers before wildcard ones. The first
canHandlethat returns true wins, and a wildcard registered first claims what a later specific handler would have taken. - Set
hostsonRouteDeeplinkHandler.nullclaims a matching path on any host. When set, a relative URI (a push payload path) always passes, and an absolute one is claimed only overhttporhttps, with no explicit port and no userinfo, on a host equal to an entry, ignoring case. A blank entry is ignored, so['']refuses every absolute URI. :namematches one path segment and*matches anything, slashes included; a trailing slash is dropped before matching. Matching ignores case unlesscaseSensitive: true, which is what a go_router app wants, since/INCIDENTS/5would otherwise be claimed and then land on the not-found page.- A custom
DeeplinkHandlerreturnsFuture<bool>fromhandleand never throws. The manager does not catch: the provider logs the error and the link is lost, and no later handler is tried.RouteDeeplinkHandlerfollows the rule itself: a navigation that fails, such as theStateErrorof a router not built yet, is logged when alogbinding exists and answeredfalse. handletakes a requiredDeeplinkSource source. Readpayload, or act on anything beyond the path, only whensource == DeeplinkSource.push: anosLinkis whatever the device was asked to open and anyone can craft one, and it carries no payload.manualis your ownhandleUricall.- Move the session's tenant with
TenantSwitchGateonRouteDeeplinkHandler(tenantGate:), never by hand-reading a query value. Only a push switches, the tenant comes from the payload underpayloadKey(default'team_id') and never from the URI query, ids compare as trimmed strings, and an absent tenant or an unresolved session navigates without switching. A switch that answersfalseor throws callsonSwitchFailedand does not navigate, because the backend would still resolve the page against the old tenant. AnonSwitchedthat throws is logged and the link still opens. DeeplinkOpenedandDeeplinkNavigatingare dispatched byRouteDeeplinkHandlerfor crash reporters. They carry the matched pattern (/invitations/:token/accept), never the path, the query or a payload value, because a link can carry a token in any of them. Do not add the concrete path to a breadcrumb.
Manager and driver rules
handleUri(uri, {required source, payload})emits the URI ononLinkfirst, claimed or not, then runs the chain. It does not wait for a frame:MagicRoute.tothrowsStateErroruntil the router is built, so a link you hand it during boot goes nowhere. AwaitWidgetsFlutterBinding.ensureInitialized().endOfFrameonce, before the first link, then call it.- Do not route
getInitialLink()as well as the provider's stream.app_linksdelivers the cold-start link as the first emission ofonLink, so reading both runs the chain twice for one tap. The provider never callsgetInitialLink(). manager.driverthrowsDeeplinkExceptionwith codeNO_DRIVERwhen none is set.AppLinksDriver.isSupportedis true on Android, iOS and macOS only; on web, Windows and Linux the provider sets no driver and subscribes to nothing, so readdriverbehind a catch or not at all.- The provider wires only
AppLinksDriver. A customDeeplinkDriverneedsmanager.setDriver, your owninitialize, a subscription to itsonLinkand a call tohandleUrifor each URI.setDriverreplaces the old driver without disposing it. - On web the driver is inert, because GoRouter owns the address bar. Address-bar links reach a route only with
routing.url_strategyset to'path'and a host rewrite of unknown paths toindex.html. A tapped push with the tab open still routes, through the push bridge. - macOS is wired by the provider and covered by nothing else: the install,
doctorandgeneratecover iOS and Android only.
Push bridge rules
- Nothing to write: when
app.bound('notifications')is true the provider attachesOneSignalDeeplinkHandler, which subscribes to the notification manager'sonPushClickedand callshandleUriwithDeeplinkSource.pushand the whole payload. It is not aDeeplinkHandlerand is not in the chain. - The link is the first non-empty string under
url,deep_link,linkoruriin the payload. A push with none is not a failure, and a launch URL set only on the OneSignal side is not read. - The notification manager is read structurally, so this package does not depend on
magic_notificationsand the provider order does not matter. A manager withoutonPushClicked, or an event without a readabledatamap, is reported at error level throughLogwhen alogbinding exists and routes nothing.
CLI rules
- The commands exist only after
plugin:installregisteredMagicDeeplinkDowelProvider. The package has nobin/of its own; rundart run magic:dowel deeplink:<command>. deeplink:generatetakes each value from a flag first andlib/config/deeplink.dartsecond. It writesapple-app-site-associationwhenteam_idandbundle_idresolve andassetlinks.jsonwhenpackage_nameandsha256_fingerprintsresolve; a platform with missing values is skipped with a warning and exit code0. The one exception is--paths: an explicit--paths '/*'is indistinguishable from the default, so it does not override a configpathssuch as['/invite/*'].deeplink:doctorreads the project and exits1when a check fails and0when only warnings were raised.--remotealso fetches both association files from the live domain and requiresdeeplink.domain. It cannot prove that a device matches a link to your app.- Generate into the folder the doctor looks in:
--output public/.well-knownorweb/.well-known.
Recipes
Route a link to a screen:
import 'package:magic/magic.dart';
import 'package:magic_deeplink/magic_deeplink.dart';
class AppServiceProvider extends ServiceProvider {
AppServiceProvider(super.app);
@override
void register() {}
@override
Future<void> boot() async {
DeeplinkManager().registerHandler(
RouteDeeplinkHandler(
paths: ['/monitors/:id', '/invitations/:token/accept'],
hosts: [Config.getOrFail<String>('deeplink.domain')],
),
);
}
}A handler of your own, checking where the link came from:
import 'package:magic/magic.dart';
import 'package:magic_deeplink/magic_deeplink.dart';
class InviteHandler extends DeeplinkHandler {
@override
bool canHandle(Uri uri) => uri.path.startsWith('/invite/');
@override
Future<bool> handle(
Uri uri, {
required DeeplinkSource source,
Map<String, dynamic>? payload,
}) async {
final String code = uri.pathSegments.last;
if (code.isEmpty) return false;
try {
MagicRoute.to('/invite/$code');
} on StateError {
return false; // The router is not built yet.
}
return true;
}
}Switch tenant before a push opens its page:
import 'package:magic_deeplink/magic_deeplink.dart';
void main() {
String? activeTeam = '1'; // The host's own session state.
final RouteDeeplinkHandler handler = RouteDeeplinkHandler(
paths: ['/incidents/:id'],
tenantGate: TenantSwitchGate(
currentTenantId: () => activeTeam,
switchTenant: (String teamId) async {
activeTeam = teamId;
return true;
},
),
);
DeeplinkManager().registerHandler(handler);
}See every link the manager is handed:
import 'package:flutter/foundation.dart';
import 'package:magic_deeplink/magic_deeplink.dart';
void main() {
DeeplinkManager().onLink.listen((Uri uri) => debugPrint('link: $uri'));
}Testing
No mocking library is needed. DeeplinkManager is a singleton that outlives the container, so call DeeplinkManager().reset() in setUp and tearDown: it clears the handlers and the driver, drops the cached initial link and replaces the onLink controller. Call MagicApp.reset() before a provider test, then register() and await boot() on DeeplinkServiceProvider(app, driverFactory: () => fakeDriver): the real driver answers isSupported from the host platform, so pass a subclass of DeeplinkDriver instead. Drive the chain with DeeplinkManager().handleUri(uri, source: DeeplinkSource.osLink). With no router built, RouteDeeplinkHandler.handle answers false rather than throwing, so assert matching with canHandle and navigation in a widget test with real routes.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

