Member-only story

🚀 “The Power of Linking in React Native: Open Apps, Websites & More”

Jayant Kumar🇮🇳
2 min read1 day ago

--

Photo by GR Stocks on Unsplash

In this guide we will talk about the power of Linking Api in React Native. It is used to handle deep linking , open external URL’s , navigate to app settings , initiate phone calls and send emails etc.

🚀 Importing Linking

To use the Linking API, you need to import it from React Native:

import { Linking } from 'react-native';

🚀 Opening External Links

You can use the openURL() method to open a link in the default browser.

const openWebsite = () => {
Linking.openURL('https://www.google.com');
};

🚀 Checking If a URL Can Be Opened

Before opening a URL, you can check if it is supported using canOpenURL().

const openUrlSafely = async (url: string) => {

const supported = await Linking.canOpenURL(url);

if (supported) {
await Linking.openURL(url);
} else {
console.log(`Cannot open URL: ${url}`);
}

};

🚀 Opening Specific Apps

You can open apps like dialer, email, WhatsApp, etc. by using specific URL schemes.

--

--

Jayant Kumar🇮🇳
Jayant Kumar🇮🇳

Written by Jayant Kumar🇮🇳

Hello My name is Jayant Kumar, I am a software Engineer , specialist in Mobile Development (Android , IOS , Flutter , React Native and Ionic) from India 🇮🇳

No responses yet