An API that provides methods to create and open deep links universally.
GitHub
npm
expo-linking
provides utilities for your app to interact with other installed apps using deep links. It also provides helper methods for constructing and parsing deep links into your app. This module is an extension of the React Native Linking module.
For a more comprehensive explanation of how to use expo-linking
, refer to the Linking guide.
Android Device | Android Emulator | iOS Device | iOS Simulator | Web |
---|---|---|---|---|
-Â
npx expo install expo-linking
If you are installing this in an existing React Native app (bare workflow), start by installing expo
in your project. Then, follow the additional instructions as mentioned by library's README under "Installation in bare React Native projects" section.
import * as Linking from 'expo-linking';
useURL()
Returns the initial URL followed by any subsequent changes to the URL.
string | null
Returns the initial URL or null
.
Linking.canOpenURL(url)
Name | Type | Description |
---|---|---|
url | string | The URL that you want to test can be opened. |
Determine whether or not an installed app can handle a given URL.
On web this always returns true
because there is no API for detecting what URLs can be opened.
Promise<boolean>
A Promise
object that is fulfilled with true
if the URL can be handled, otherwise it
false
if not.
The Promise
will reject on Android if it was impossible to check if the URL can be opened, and
on iOS if you didn't add the specific scheme in the LSApplicationQueriesSchemes
key inside Info.plist.
Linking.collectManifestSchemes()
Collect a list of platform schemes from the manifest.
This method is based on the Scheme
modules from @expo/config-plugins
which are used for collecting the schemes before prebuilding a native app.
string[]
Linking.createURL(path, namedParameters)
Name | Type | Description |
---|---|---|
path | string | Addition path components to append to the base URL. |
namedParameters (optional) | CreateURLOptions | Additional options object. Default: {} |
Helper method for constructing a deep link into your app, given an optional path and set of query parameters. Creates a URI scheme with two slashes by default.
The scheme in bare and standalone must be defined in the Expo config (app.config.js
or app.json
)
under expo.scheme
.
<scheme>://path
- uses provided scheme or scheme from Expo config scheme
.yourscheme://path
https://localhost:19006/path
https://myapp.com/path
exp://128.0.0.1:8081/--/path
exp://exp.host/@yourname/your-app/--/path
string
A URL string which points to your app with the given deep link information.
Linking.getInitialURL()
Get the URL that was used to launch the app if it was launched by a link.
Promise<string | null>
The URL string that launched your app, or null
.
Linking.hasConstantsManifest()
Ensure the user has linked the expo-constants manifest in bare workflow.
boolean
Linking.hasCustomScheme()
boolean
Deprecated An alias for
createURL()
. This method is deprecated and will be removed in a future SDK version.
Linking.makeUrl(path, queryParams, scheme)
Name | Type | Description |
---|---|---|
path (optional) | string | addition path components to append to the base URL. Default: '' |
queryParams (optional) | ParsedQs | An object with a set of query parameters. These will be merged with any Expo-specific parameters that are needed (e.g. release channel) and then appended to the URL as a query string. |
scheme (optional) | string | Optional URI protocol to use in the URL |
Create a URL that works for the environment the app is currently running in.
The scheme in bare and standalone must be defined in the app.json under expo.scheme
.
yourscheme:///path
https://localhost:19006/path
https://myapp.com/path
exp://128.0.0.1:8081/--/path
exp://exp.host/@yourname/your-app/--/path
string
A URL string which points to your app with the given deep link information.
Linking.openSettings()
Open the operating system settings app and displays the app’s custom settings, if it has any.
Promise<void>
Linking.openURL(url)
Name | Type | Description |
---|---|---|
url | string | A URL for the operating system to open, eg: |
Attempt to open the given URL with an installed app. See the Linking guide for more information.
Promise<true>
A Promise
that is fulfilled with true
if the link is opened operating system
automatically or the user confirms the prompt to open the link. The Promise
rejects if there
are no applications registered for the URL or the user cancels the dialog.
Linking.parse(url)
Name | Type | Description |
---|---|---|
url | string | A URL that points to the currently running experience (e.g. an output of |
Helper method for parsing out deep link information from a URL.
A ParsedURL
object.
Linking.parseInitialURLAsync()
Helper method which wraps React Native's Linking.getInitialURL()
in Linking.parse()
.
Parses the deep link information out of the URL used to open the experience initially.
If no link opened the app, all the fields will be null
.
On the web it parses the current window URL.
A promise that resolves with ParsedURL
object.
Linking.sendIntent(action, extras)
Name | Type |
---|---|
action | string |
extras (optional) | SendIntentExtras[] |
Launch an Android intent with extras.
Use IntentLauncher instead,
sendIntent
is only included inLinking
for API compatibility with React Native's Linking API.
Promise<void>
Linking.addEventListener(type, handler)
Name | Type | Description |
---|---|---|
type | 'url' | The only valid type is |
handler | URLListener | An |
Add a handler to Linking
changes by listening to the url
event type and providing the handler.
It is recommended to use the useURL()
hook instead.
An EmitterSubscription that has the remove method from EventSubscription
CreateURLOptions
Name | Type | Description |
---|---|---|
isTripleSlashed (optional) | boolean | Should the URI be triple slashed |
queryParams (optional) | QueryParams | An object of parameters that will be converted into a query string. |
scheme (optional) | string | URI protocol |
EventType
Name | Type | Description |
---|---|---|
nativeEvent (optional) | MessageEvent | - |
url | string | - |
NativeURLListener()
Name | Type |
---|---|
nativeEvent | MessageEvent |
ParsedURL
Name | Type | Description |
---|---|---|
hostname | string | null | - |
path | string | null | The path into the app specified by the URL. |
queryParams | QueryParams | null | The set of query parameters specified by the query string of the url used to open the app. |
scheme | string | null | - |
QueryParams
Type: ParsedQs
SendIntentExtras
Name | Type | Description |
---|---|---|
key | string | - |
value | string | number | boolean | - |
URLListener()
Name | Type |
---|---|
event | EventType |