---
title: "Callbacks"
description: "Learn how to use callbacks to respond to c15t events in your React application."
lastModified: 2025-08-20
availableIn:
  - framework: 'next'
    url: '/docs/frameworks/next/callbacks'
    title: 'Next.js'
  - framework: 'react'
    url: '/docs/frameworks/react/callbacks'
    title: 'React'
---
## Implementing Callbacks

```tsx title="src/App.tsx"
import { 
  ConsentManagerDialog,
  ConsentManagerProvider,
  CookieBanner,
  type ConsentManagerOptions
} from '@c15t/react';

export default function App() {
  const options: ConsentManagerOptions = {
    mode: 'c15t', 
    backendURL: process.env.REACT_APP_C15T_URL,
    consentCategories: ['necessary', 'marketing'], // Optional: Specify which consent categories to show in the banner. 
    ignoreGeoLocation: true, // Useful for development to always view the banner.
    callbacks: {
      onBannerFetched(response) {
        console.log('Consent banner fetched', response);
      },
      onConsentSet(response) {
        console.log('Consent has been saved', response);
      },
      onError(response) {
        console.log('Error', response);
      },
    },
  };

  return (
    <ConsentManagerProvider options={options}>
      <div className="App">
        {/* Your application content */}
      </div>
      <CookieBanner />
      <ConsentManagerDialog />
    </ConsentManagerProvider>
  );
}
```

## Available callbacks

### onBannerFetched

Called when the consent banner is fetched; not invoked when the banner is in offline mode.

| Property               | Type                   | Description                           | Default |  Required  |
| :--------------------- | :--------------------- | :------------------------------------ | :------ | :--------: |
| OnBannerFetchedPayload | OnBannerFetchedPayload | Type alias for OnBannerFetchedPayload | -       | ✅ Required |

### onConsentSet

Called when the consent is set.

| Property            | Type                | Description                        | Default |  Required  |
| :------------------ | :------------------ | :--------------------------------- | :------ | :--------: |
| OnConsentSetPayload | OnConsentSetPayload | Type alias for OnConsentSetPayload | -       | ✅ Required |

### onError

Called when an error occurs.

| Property       | Type           | Description                   | Default |  Required  |
| :------------- | :------------- | :---------------------------- | :------ | :--------: |
| OnErrorPayload | OnErrorPayload | Type alias for OnErrorPayload | -       | ✅ Required |
