What is expo-linking?
The expo-linking package is a part of the Expo ecosystem and provides utilities for handling deep links and URLs in React Native applications. It allows you to open URLs, handle incoming links, and parse URLs to extract information.
What are expo-linking's main functionalities?
Open URLs
This feature allows you to open a URL in the device's default web browser. The code sample demonstrates how to use the openURL method to open a web page.
import * as Linking from 'expo-linking';
Linking.openURL('https://example.com');
Handle Incoming Links
This feature allows you to handle incoming links by adding an event listener for URL events. The code sample shows how to log the incoming URL when the event is triggered.
import * as Linking from 'expo-linking';
Linking.addEventListener('url', (event) => {
console.log('Incoming URL:', event.url);
});
Parse URLs
This feature allows you to parse URLs to extract information such as the path and query parameters. The code sample demonstrates how to parse a URL and log the parsed object.
import * as Linking from 'expo-linking';
const url = 'https://example.com/path?name=value';
const parsed = Linking.parse(url);
console.log(parsed);
Other packages similar to expo-linking
react-native-deep-linking
The react-native-deep-linking package provides similar functionality for handling deep links in React Native applications. It allows you to register and handle deep links, but it does not offer the same level of integration with the Expo ecosystem as expo-linking.
react-native-url-handler
The react-native-url-handler package is another alternative for handling URLs and deep links in React Native applications. It provides utilities for opening URLs and handling incoming links, similar to expo-linking, but it is not specifically designed for use with Expo.
expo-linking
Create and open deep links universally.
API documentation
Installation in managed Expo projects
For managed Expo projects, please follow the installation instructions in the API documentation for the latest stable release. If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
Installation in bare React Native projects
For bare React Native projects, you must ensure that you have installed and configured the expo
package before continuing.
Add the package to your npm dependencies
npx expo install expo-linking
Contributing
Contributions are very welcome! Please refer to guidelines described in the contributing guide.