```tsx
import {AiChat, PreDestroyCallback, PreDestroyEventDetails} from '@nlux/react';
import {useCallback} from 'react';

const preDestroyCallback = useCallback<PreDestroyCallback>((preDestroyDetails: PreDestroyEventDetails) => {
    if (preDestroyDetails.conversationHistory > 0) {
        // Do something with the conversation history before it is destroyed
    }
}, [/* Callback dependencies */]);
```

```tsx
// Provide the preDestroy callback as part of the events prop
<AiChat events={{preDestroy: preDestroyCallback}} adapter={adapter} />
```
