Skip to content

openURL

Opens the specified URL in the device's default browser or related app. This function uses the Linking.openURL method from react-native to open the URL.

Signature

typescript
function openURL(url: string): Promise<any>;

Parameter

  • urlrequired · string

    URL address to open

Return Value

  • Promise<any>

    Promise that resolves when the URL is successfully opened

Example

Open external URL

tsx
import { openURL } from '@granite-js/react-native';
import { Button } from 'react-native';

function Page() {
  const handlePress = () => {
    openURL('https://google.com');
  };

  return <Button title="Open Google Website" onPress={handlePress} />;
}