import { StreamChat } from "stream-chat";
import { ChannelList, Chat, OverlayProvider } from "stream-chat-react-native";
const client = StreamChat.getInstance("api_key");
export const App = () => (
<OverlayProvider>
<Chat client={client}>
<ChannelList />
</Chat>
</OverlayProvider>
);OverlayProvider
OverlayProvider is the top-level Stream Chat React Native component. It wraps all other SDK components and enables long-press message actions and the full-screen image viewer.
Best Practices
- Wrap your entire app (or top navigation tree) to avoid context mismatches.
- Keep
OverlayProviderstable; avoid re-mounting it on screen changes. - Use the provided hooks instead of prop drilling for overlay contexts.
- Customize subcomponents via
imageGalleryCustomComponentsrather than replacing the full image viewer. - Pass theming via
value.styleto keep UI consistent across screens.
General Usage
Wrap all Stream Chat components with OverlayProvider (usually the whole app).
Note: For navigation details, see the Navigation guide.
Context Providers
OverlayProvider provides AttachmentPickerContext, ImageGalleryContext, OverlayContext, ThemeContext, and TranslationContext. Use the corresponding hooks to access them.
| Context | Hook |
|---|---|
ImageGalleryContext | useImageGalleryContext |
OverlayContext | useOverlayContext |
ThemeContext | useTheme |
TranslationContext | useTranslationContext |
Props
autoPlayVideo
Enable or disable autoplay for overlay videos.
| Type | Default |
|---|---|
| Boolean | false |
giphyVersion
Giphy image rendition to use in the Image Gallery. See the Image Object keys for options.
| Type | Default |
|---|---|
| String | 'fixed_height' |
i18nInstance
Streami18n instance used for internationalization. See the translations docs for setup and customization.
| Type |
|---|
Streami18n |
imageGalleryCustomComponents
ImageGallery renders the image viewer and handles zoom/swipe gestures. You can't replace the whole component, but you can replace subcomponents via imageGalleryCustomComponents. Each key maps to a subcomponent and its props are spread onto that component.
footer-> ImageGalleryFootergrid-> ImageGridgridHandle-> ImageGridHandleheader-> ImageGalleryHeader
| Type |
|---|
| Object |
imageGalleryGridHandleHeight
Height of the image gallery grid bottom sheet handle.
| Type | Default |
|---|---|
| Number | 40 |
imageGalleryGridSnapPoints
The SnapPoints for the image gallery grid bottom sheet.
| Type | Default |
|---|---|
| Array | [0, (screenHeight * 9) / 10] |
numberOfImageGalleryGridColumns
Number of columns to render within the image gallery grid.
| Type | Default |
|---|---|
| Number | 3 |
value
Partially overrides the value provided to the OverlayContext. This prop can be used to set the theme via the style key.
const theme = {
messageSimple: {
file: {
container: {
backgroundColor: "red",
},
},
},
};
<OverlayProvider value={{ style: theme }}>...</OverlayProvider>;| Type |
|---|
| Object |