> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cskn.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Share

> Open the system share sheet for text, links, files and generated documents.

## Text and links

```tsx theme={null}
import { useShare } from '@cskn/sdk';

function ShareButton({ url }: { url: string }) {
  const share = useShare();
  return (
    <button onClick={() => share.open({ title: 'Look at this', message: 'Found it on cskn', url })}>
      Share
    </button>
  );
}
```

`open({ title?, message?, url? })` resolves `true` when the user shared.

For links to a profile, build the URL with [`userPageUrl`](/sdk/urls#shareable-links), not `window.location`.

## Files on the device

```tsx theme={null}
const result = await share.shareFile({
  uri: shot.video!.nativeUri!,
  mimeType: 'video/mp4',
  dialogTitle: 'Share clip',  // Android only
});
if (result.error === 'not_available') {
  // this device cannot share files
}
```

`uri` must be a file the shell can read, such as a `nativeUri` returned by the [camera](/sdk/native/camera).

## Generated documents

`shareContent` shares a file your page built itself, such as an export or a PDF. Inside a shell, `<a download>` and `window.print()` do nothing, so this is how a user gets the file out.

```tsx theme={null}
import { shareContent } from '@cskn/sdk';

const result = await shareContent({
  data: csvText,
  fileName: 'expenses.csv',
  mimeType: 'text/csv',
});
if (result.error === 'not_available') downloadInBrowser(csvText);
```

<ParamField path="data" type="string" required>The file contents.</ParamField>
<ParamField path="encoding" type="'utf8' | 'base64'" default="'utf8'">Use `base64` for binary files.</ParamField>
<ParamField path="fileName" type="string" required>Name the shell saves it under.</ParamField>
<ParamField path="mimeType" type="string">Content type.</ParamField>
<ParamField path="dialogTitle" type="string">Share sheet title (Android).</ParamField>

It resolves `{ shared?, error? }`, with `error` being `not_available` or `failed`. It answers `not_available` outside a shell and in shell versions that predate it, so always keep a browser download path.

<Note>
  Outside a shell, `open` resolves `false` and `shareFile` resolves `error: 'not_available'`. In a browser, use `navigator.share` or a download link.
</Note>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.