---
title: useOptimizelyClient for the React Native SDK v4+
slug: feature-experimentation/docs/useoptimizely-client-for-the-react-native-sdk
docTags: 
createdAt: 2026-08-05T20:39:51.000Z
---

## Minimum SDK version

v4.0.0+

For versions 3.x and earlier, the equivalent functionality was provided by the `withOptimizely` higher-order component. See [React Native SDK prior to v4](docId\:qJ2ssIUv5BsJE1fQSn75a).

## Description

The `useOptimizelyClient` hook returns the Optimizely `Client` instance from context. Use this hook when you need direct access to the client for operations not covered by the decide hooks.

To use this hook, call `useOptimizelyClient` within a component wrapped by `OptimizelyProvider`. See [OptimizelyProvider for the React Native SDK](docId\:nZHEmzX-G_Fs-aXE-0lYr).

## Returns

Returns the Optimizely `Client` instance provided to `<OptimizelyProvider>` via the `client` prop.

## Example

```javascript
import { Text, TouchableOpacity } from 'react-native';
import { useOptimizelyClient } from '@optimizely/react-sdk';

function MyComponent() {
  const client = useOptimizelyClient();

  const handlePress = () => {
    if (client) {
      const user = client.createUserContext('user-123', { plan: 'gold' });
      const decision = user.decide('flag-key');
      console.log('Decision:', decision);
    }
  };

  return (
    <TouchableOpacity onPress={handlePress}>
      <Text>Check Flag</Text>
    </TouchableOpacity>
  );
}
```

## Source files

The language and platform source files containing the implementation for the React Native SDK are available on [GitHub](https://github.com/optimizely/react-sdk).
