> ## 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.

# URLs and routing

> Mount your router correctly and build links that work on every host.

Apps and people live on different domains:

| What | Address |
| - | - |
| An app | `https://<slug>.cskn.app` |
| An app on someone's profile | `https://<username>.cskn.my/<slug>` |

Do not derive one from the other, and do not build them from `window.location`: inside a native shell your page may be running on a host nobody else can reach.

## Routing

The same bundle is mounted at `/` on the app's host and at `/<slug>` on a profile. The host tells you which.

```tsx theme={null}
import { BrowserRouter } from 'react-router-dom';
import { appBasename } from '@cskn/sdk';

<BrowserRouter basename={appBasename()}>…</BrowserRouter>
```

| Function | Returns |
| - | - |
| `getMountPath()` | `''` or `'/<slug>'`, never with a trailing slash. |
| `appBasename()` | `getMountPath()`, with the root spelled `'/'`. Pass it to your router. |
| `appHref(path)` | An absolute URL for an in-app route on the current host, for OAuth or payment return URLs. |

<Warning>
  Never redirect a `/<slug>` path to `/<slug>/` or re-mount it yourself. An app can legitimately have a route that shares its slug's name.
</Warning>

## Shareable links

```tsx theme={null}
import { userPageUrl, appUrl } from '@cskn/sdk';

userPageUrl('ada', 'photos');            // https://ada.cskn.my/photos
userPageUrl('ada', 'photos', '/p/42');   // https://ada.cskn.my/photos/p/42
appUrl('photos');                        // https://photos.cskn.app
```

Use `userPageUrl` for anything a person will paste elsewhere: a share sheet, a copied link, a preview card. When the page is already the owner's own user page, it keeps the current origin, so a profile reached through a custom domain shares as that domain.

## getHostnameUsername

Returns the profile owner's username: from the injected app data when present, otherwise from the first label of the hostname. On `localhost` it returns a fixed development name. Prefer `getAppUser()` in new code.


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