Deep links

This app supports deep links in web and native (Capacitor) contexts.

Entry points

  • Web fallback page: /open route (client/src/utils/Open.js)
  • Native handlers (mounted in client/src/App.js):
    • BranchDeepLinkHandler (client/src/utils/BranchDeepLinkHandler.js)
    • DeepLinkHandler (client/src/utils/DeepLinkHandler.js)

Deep links commonly set these localStorage keys:

  • intendedVenue: venue id (from venue= or /venue/:id)
  • intendedVenueRef: referral/ref code (from ref=)
  • pendingServerCode: signup server code (created in Branch.io and delivered to the app as a link parameter)

Venue parsing/storage is implemented in:

  • client/src/utils/appDeeplink.js (storeIntendedVenueFromUrlFromString)

Signup/server code

  • .../open?server_code=XXXX
  • any URL with server_code or serverCode query param

Behavior:

  • store pendingServerCode
  • navigate to /signup

Where the server code comes from:

  • The value is set when you generate/configure the Branch.io link (as server_code or serverCode).
  • On native, the app reads it from Branch “referring params” (it checks top-level params and also nested data / control_params).

Venue

  • .../open?venue=123
  • https://getfoodfight.link/venue/123
  • foodfight://open?venue=123

Behavior:

  • store intendedVenue
  • navigate to /app/restaurant

Lucra

Both native handlers try to detect Lucra links and call:

  • handleLucraDeeplink(...) (from client/src/utils/lucraUtils)

Native (Capacitor) behavior

BranchDeepLinkHandler listens to Branch events via capacitor-branch-deep-links:

  • init
  • deferredDeepLink
  • initError

It extracts server code from multiple possible Branch param locations (top-level, data, control_params) and supports retrying getLatestReferringParams() on appStateChange because some in-app browsers don’t reliably deliver URLs.

Generic URL handler (Capacitor appUrlOpen)

DeepLinkHandler listens to:

  • cold start: CapacitorApp.getLaunchUrl()
  • warm: CapacitorApp.addListener('appUrlOpen', ...)

It also has special logic to resolve Branch short links (*.app.link) by fetching the URL and extracting server_code from redirects or interstitial HTML.

Web behavior (/open)

Open.js is a lightweight landing route that:

  • stores venue, ref, server_code into localStorage
  • attempts to generate a Branch short link via generateBranchLink (client/src/utils/BranchLinkGenerator.js)
  • falls back to:
    • iOS: attempt foodfight://open?... then App Store
    • Android/desktop: redirect to web signup (https://www.getfoodfight.link/signup)

Debugging

Both native handlers support a lightweight debug trail:

  • enable: localStorage.setItem('dlDbgEnabled', '1')
  • logs: console prefix [DLDBG]
  • trail: localStorage['dlDbgTrail'] (last ~30 events)