> ## Documentation Index
> Fetch the complete documentation index at: https://replyke-feat-push-rich-payload-fields.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Push Notifications

> Register the current user's device for native push from your client app

This page covers **registering devices from your client SDK**. For the full feature overview — dashboard setup, server-side sending, and device lifecycle — see [Push Notifications](/push-notifications).

<Note>
  **Requires the `push` bundle** and configured provider credentials (APNs, FCM, or Web Push) in the dashboard. See the [feature overview](/push-notifications#dashboard-setup) for setup.
</Note>

## Registering Devices

Use `usePushRegistration` with the adapter for your platform. Call `register()` in response to a deliberate user action — not on mount — because requesting OS push permission is a one-shot prompt that users cannot undo.

```tsx theme={null}
// Expo
import { usePushRegistration } from "@sublay/core";
import { expoPushTokenAdapter } from "@sublay/expo";

function SettingsScreen() {
  const { register, registering } = usePushRegistration(expoPushTokenAdapter);
  return <Button onPress={register} loading={registering} title="Enable notifications" />;
}
```

```tsx theme={null}
// Bare React Native
import { usePushRegistration } from "@sublay/core";
import { reactNativePushTokenAdapter } from "@sublay/react-native";

const { register } = usePushRegistration(reactNativePushTokenAdapter);
```

```tsx theme={null}
// Web (browser)
import { usePushRegistration } from "@sublay/core";
import { webPushTokenAdapter } from "@sublay/react-js";

const { register, unregister } = usePushRegistration(webPushTokenAdapter);
```

The web adapter requires a service worker. Register one before calling `register()`. The public VAPID key your service worker needs is available from the unauthenticated [`GET /vapid-public-key`](/api-reference/push-notifications/get-vapid-public-key) endpoint.

## Unregistering on Logout

Call `unregister()` in your logout flow so the device stops receiving notifications after sign-out:

```tsx theme={null}
const { unregister } = usePushRegistration(webPushTokenAdapter);

async function handleLogout() {
  await unregister();
  // ...clear session
}
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Feature Overview" icon="bell" href="/push-notifications">
    Dashboard setup, sending, and device lifecycle
  </Card>

  <Card title="usePushRegistration" icon="cube" href="/hooks/push/use-push-registration">
    The full hook API and platform adapters
  </Card>
</CardGroup>
