---
source_url: https://www.pubnub.com/docs/sdks/react/api-reference/consumer
title: PubNub Consumer
updated_at: 2026-06-16T12:52:18.605Z
---

> 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


# PubNub Consumer

A `PubNubConsumer` allows you to access the client instance you made available with a `PubNubProvider`.

## PubNubConsumer props

The `PubNubConsumer` component takes a single prop: `client` is the required `pubNubClient` instance. This is used by all components that require PubNub functionality.

## PubNubConsumer example

Once you've created a `PubNubProvider`, you can access the client with a `PubNubConsumer`:

```jsx
import React from 'react';
import PubNub from 'pubnub';
import { PubNubProvider } from '../PubNubProvider';
import { PubNubConsumer } from '../PubNubConsumer';
import { getPubNubContext } from '../PubNubContext';

const pubNubConfig = require('../config/pubnub.json');
const pubNubClient = new PubNub(pubNubConfig.Demo.keySet);

const App = () => {
  <PubNubProvider client={pubNubClient}>
    <PubNubConsumer>
      {client => "success!" /* do something now */ }
    </PubNubConsumer>
  </PubNubProvider>
};
```