---
source_url: https://www.pubnub.com/docs/sdks/react/api-reference/hooks
title: usePubNub Hook
updated_at: 2026-06-19T11:38:28.869Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# usePubNub Hook

The `usePubNub` hook lets you interact with PubNub in function components.

Hooks are a new feature added in React 16.8 that allow you to use React features without writing a class. For a general overview of hooks, refer to [the React documentation](https://reactjs.org/docs/hooks-intro.html).

## Example

```jsx
import React from 'react';
import { usePubNub } from '../../src/index';

const PubNubTime = () => {
  const PubNubClient = usePubNub();

  return (
    <div>
      const [time, setTime] = useState("Loading");

      PubNubClient.time((status, response) => setTime(response.timetoken));

      {time}
    </div>
  );
};

export default PubNubTime;
```