Skip to main content
Integrate with a back navigation control provided by the Farcaster client.

Usage

If your application is already using browser-based navigation, you can integrate in one line with:
That’s it! When there is a page to go back to a back control will be made available to the user. Otherwise, you can set a custom back handler and show the back control:

Back control

The back control will vary depending on the user’s device and platform but will generally follow:
  • a clickable button in the header on web
  • a horizontal swipe left gesture on iOS
  • the Android native back control on Android which could be a swipe left gesture combined with a virtual or physical button depending on the device

Web Navigation integration

The SDK can automatically integrate with web navigation APIs.

enableWebNavigation()

Enables automatic integration with the browser’s navigation system. This will:
  • Use the modern Navigation API when available; the back button will automatically be shown and hidden based on the value of canGoBack.
  • Fall back to the History API in browsers where Navigation is not supported ; the back button will always be shown.

disableWebNavigation()

Disables web navigation integration.

Properties

enabled

  • Type: boolean
  • Description: Whether back navigation is currently enabled

onback

  • Type: () => unknown
  • Description: Function to call when a back event is triggered. You don’t need to set this when using enableWebNavigation.

Methods

show()

Makes the back button visible.

hide()

Hides the back button.

Events

When a user triggers the back control the SDK will emit an backNavigationTriggered event. You can add an event listener on sdk or use sdk.back.onback to respond to these events. If you are using enableWebNavigation this event will automatically be listened to and trigger the browser to navigate. Otherwise you should listen for this event and respond to it as appropriate for your application.

Availability

You can check whether the Farcaster client rendering your app supports a back control:

Example: Web Navigation

Example: Manual