Skip to main content

Routing to Private Content

You can deep-link to anything in your app — private posts, gated dashboards, user-specific records, paywalled articles, multi-tenant resources. Ulinkly resolves the link to a destination; your app decides who's allowed to see it.

TL;DR​

The pattern in one snippet — receive the link, check auth, render or deflect:

ulink.dynamicLinkStream.sink { data in
guard let route = data.parameters?["route"] as? String else { return }
if AuthService.shared.isSignedIn, PermissionService.shared.canView(route) {
navigate(to: route)
} else {
presentSignIn(thenResumeTo: route)
}
}.store(in: &cancellables)

In the Swift and Kotlin samples, ulink is the instance returned by ULink.initialize (on Android, ULink.getInstance()). The Kotlin samples read parameters as JSON, so they need kotlinx.serialization.json.JsonObject, jsonPrimitive and contentOrNull imports. The link must be a dynamic link that carries a route parameter; see Create the link.

That's the pattern. The rest of this page explains why it works, the step-by-step, and the rough edges.

The core idea: Ulinkly routes, your app authorizes​

Ulinkly is the routing layer. Your app is the authorization layer. The two are deliberately separate.

When a user taps a deep link, Ulinkly resolves it to a destination inside your app — typically an in-app route like post/abc123 that you store in the link's parameters. Ulinkly doesn't know whether the user is signed in, who they are, or what they're allowed to see. It hands the destination to your app, and your app applies whatever auth and permission rules you've already built.

This is a feature, not a workaround. We don't ship a "Ulinkly-style auth" because every team brings their own — Firebase Auth, Supabase, Clerk, Auth0, Cognito, a custom JWT service. An opinionated integration would force you to give up choices that are usually deeply embedded in your app. By staying auth-agnostic, Ulinkly composes cleanly with whatever you already have.

The pattern, step by step​

When you create the link, use a dynamic link and put the in-app destination (a route or path your app already knows how to render) in its parameters. Don't put user IDs, session tokens, or sensitive data in the URL itself.

let params = ULinkParameters.dynamic(
domain: "links.acme.com",
slug: "postabc123",
iosFallbackUrl: "https://apps.apple.com/app/acme/id0000000000",
androidFallbackUrl: "https://play.google.com/store/apps/details?id=com.acme",
fallbackUrl: "https://acme.com/p/abc123",
parameters: ["route": "post/abc123"]
)
let response = try await ulink.createLink(parameters: params)

The app opens the link through the project's deep linking scheme and receives the link's parameters. Route on a parameter such as route, not on the slug: the slug is the short URL's ID, and Ulinkly generates one if you don't set it.

Your platform-specific deep-link handler receives the destination from Ulinkly. See the platform guides (iOS, Android, Flutter, React Native) for the wiring.

3. Check auth and authorize​

Before rendering, run your normal auth and permission checks:

ulink.dynamicLinkStream.sink { data in
guard let route = data.parameters?["route"] as? String else { return }
switch (AuthService.shared.isSignedIn, PermissionService.shared.canView(route)) {
case (false, _): deflectToSignIn(targetRoute: route)
case (true, false): showNotAuthorized()
case (true, true): navigate(to: route)
}
}.store(in: &cancellables)

The check can be as simple as "is the user signed in" or as rich as a full RBAC/ABAC evaluation. Ulinkly doesn't care.

4. Render or deflect​

If access is granted, render the destination. If not, deflect to sign-in, paywall, request-access, or whatever your product does for unauthorized users.

Handling the "user isn't signed in" case​

This is the most common rough edge. The user opens a link, your app launches, and the user isn't authenticated. Two patterns work well.

Defer the destination in app state. Store the pending route somewhere (a singleton, persistent storage, or your state management layer) and replay it after sign-in completes.

final class DeepLinkRouter {
static let shared = DeepLinkRouter()
private var pending: String?

func handle(_ route: String) {
if AuthService.shared.isSignedIn {
navigate(to: route)
} else {
pending = route
AuthService.shared.presentSignIn { [weak self] in
if let s = self?.pending { self?.navigate(to: s); self?.pending = nil }
}
}
}
}

Use deferred deep linking for the install case. When the link is tapped by someone who doesn't have your app installed, Ulinkly can preserve the destination across the install → first-launch boundary. See the platform guides for the deferred-link APIs.

What NOT to put in the URL​

The URL is visible to anyone who has the link, plus anyone who scrapes referer headers, social previews, or share-sheet captures. Treat it as public even when the destination is private.

Don'tUse instead
User IDs, account numbersOpaque slugs (abc123) generated server-side
Session tokens, API keysStandard auth headers / cookies in your app
PII (email, phone, SSN)An in-app fetch keyed on the route, after auth
Payment / order detailsA record ID; fetch the rest after auth

Treat parameters (including route) as visible: anyone with the link can resolve it.

Vertical examples​

The pattern is identical across verticals; only the auth check differs.

  • B2B SaaS — a shared dashboard link. Your app checks that the recipient is on the workspace and has read permission for the dashboard.
  • Social network — a profile or post link. Your app checks visibility (public / followers-only / private) against the viewer's relationship.
  • Fintech — a transaction or invoice link. Your app re-authenticates with biometrics, then checks that the recipient owns the record. See Fintech use cases for the security framing.
  • Healthcare — a patient record or appointment link. Your app checks that the signed-in user is allowed to see that record. See Health use cases.
  • E-commerce — a wishlist or cart-share link. Your app checks whether the resource was set to "shareable" by the owner, and applies any rate limits.
  • Education — a course module or assignment link. Your app checks enrollment, cohort, and unlock state.

In every case Ulinkly does the same thing: resolve the link, hand off the destination. The differences live entirely on your side, where they should.