Skip to main content

Overview

Returns a function to open URLs through the host application. The host controls how the link is opened (new tab, in-app browser, etc.).

Import

import { useOpenLink } from 'sunpeak';

Signature

function useOpenLink(): (params: OpenLinkParams) => Promise<void>

OpenLinkParams

url
string
required
The URL to open.

Returns

Function to open a URL through the host application.

Usage

import { useOpenLink } from 'sunpeak';

function MyResource() {
  const openLink = useOpenLink();

  return (
    <button onClick={() => openLink({ url: 'https://example.com' })}>
      Visit Website
    </button>
  );
}