# Error Using ApolloProvider, cannot read properties of undefined (reading 'Symbol(\_\_APOLLO\_CONTEXT\_\_)')

**URL:** <https://community.apollographql.com/t/error-using-apolloprovider-cannot-read-properties-of-undefined-reading-symbol-apollo-context/8511>\
**Category:** Client SDKs\
**Tags:** client\
**Created:** [February 12, 2025, 8:24pm UTC](https://community.apollographql.com/t/error-using-apolloprovider-cannot-read-properties-of-undefined-reading-symbol-apollo-context/8511 "2025-02-12T20:24:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim-S](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/tim-s/32/5740_2.png) [@Tim-S](https://community.apollographql.com/u/Tim-S)\
**Post date:** [February 12, 2025, 8:24pm UTC](https://community.apollographql.com/t/error-using-apolloprovider-cannot-read-properties-of-undefined-reading-symbol-apollo-context/8511/1 "2025-02-12T20:24:50Z")

</div>

I am trying to set up a simple React front-end that uses ApolloClient to hit an existing GraphQL server I have running locally.

The `index.tsx` file is pretty bare-bones:

```auto
import "./styles.css";
import { createRoot } from "react-dom/client";
import { ApolloClient, ApolloProvider, InMemoryCache } from "@apollo/client";

const rootElement = document.getElementById("root");
if (!rootElement) throw new Error("Root element not found");
const root = createRoot(rootElement);

const ApiClient = new ApolloClient({
  uri: 'http://localhost:3000/api',
  cache: new InMemoryCache(),
});

root.render(
  <ApolloProvider client={ApiClient}>
    Hello World!
  </ApolloProvider>
);

```

When I run the app locally I get the following error:

```auto
..\node_modules\@apollo\client\react\context\ApolloContext.js:11 Uncaught TypeError: Cannot read properties of undefined (reading 'Symbol( __APOLLO_CONTEXT__ )')
    at getApolloContext (..\node_modules\@apollo\client\react\context\ApolloContext.js:11:25)
    at ApolloProvider (..\node_modules\@apollo\client\react\context\ApolloProvider.js:7:25)

```

Googling the error mostly turned up issues with using the provider from a server-side component in Next.js, but I’m not using Next.js. I _am_ using `bun build` to transpile the react/typescript to an .html/.js pair.

I’m beginning to suspect this may be a bun issue, but I wanted to make sure I wasn’t doing something obviously wrong before I started a conversation there.

Any thoughts/suggestions on what I might be doing wrong here?

---

<div class="post-metadata">

**Author:** ![jerelmiller](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/jerelmiller/32/3314_2.png) [@jerelmiller](https://community.apollographql.com/u/jerelmiller)\
**Post date:** [February 12, 2025, 8:37pm UTC](https://community.apollographql.com/t/error-using-apolloprovider-cannot-read-properties-of-undefined-reading-symbol-apollo-context/8511/2 "2025-02-12T20:37:32Z")

</div>

Hey @Tim-S 👋

It looks like its failing on this line from the [build output](https://unpkg.com/browse/@apollo/client@3.12.10/react/context/ApolloContext.js):

```ts
var context = React.createContext[contextKey]

```

where `contextKey` is `Symbol.for(" __APOLLO_CONTEXT__")` for environments that support symbols.

We use a symbol on `React.createContext` to access the context value in `ApolloProvider` to ensure that we get the right value in case multiple versions of React are installed.

Can you log out what you get for `React.createContext`? Seems this is `undefined` for some reason in your app.

---

<div class="post-metadata">

**Author:** ![Tim-S](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/tim-s/32/5740_2.png) [@Tim-S](https://community.apollographql.com/u/Tim-S)\
**Post date:** [February 12, 2025, 8:54pm UTC](https://community.apollographql.com/t/error-using-apolloprovider-cannot-read-properties-of-undefined-reading-symbol-apollo-context/8511/3 "2025-02-12T20:54:23Z")

</div>

Looks like it’s a function:

```auto
(defaultValue) {
      defaultValue = {
        $$typeof: REACT_CONTEXT_TYPE,
        _currentValue: defaultValue,
        _currentValue2: defaultValue,
        _threadCount: 0,
        Provider: nul…

```

The `contextKey` there is the symbol: `Symbol( __APOLLO_CONTEXT__ )` (`canUseSymbol` is true)

---

<div class="post-metadata">

**Author:** ![Tim-S](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/tim-s/32/5740_2.png) [@Tim-S](https://community.apollographql.com/u/Tim-S)\
**Post date:** [February 12, 2025, 9:18pm UTC](https://community.apollographql.com/t/error-using-apolloprovider-cannot-read-properties-of-undefined-reading-symbol-apollo-context/8511/4 "2025-02-12T21:18:55Z")

</div>

I’ve set up a minimal repro here: [GitHub - timothy-s-dev/bun-apollo-test](https://github.com/timothy-s-dev/bun-apollo-test)

---

<div class="post-metadata">

**Author:** ![jerelmiller](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/jerelmiller/32/3314_2.png) [@jerelmiller](https://community.apollographql.com/u/jerelmiller)\
**Post date:** [February 12, 2025, 11:22pm UTC](https://community.apollographql.com/t/error-using-apolloprovider-cannot-read-properties-of-undefined-reading-symbol-apollo-context/8511/5 "2025-02-12T23:22:06Z")

</div>

Huh, if I look at that `index-*.js` build file, I see the [following](https://github.com/timothy-s-dev/bun-apollo-test/blob/a11fd005a5f5db6cc48e089e6c12367d6eb9958a/dist/index-pgtkwj6h.js#L25891-L25904):

```js
function getApolloContext() {
  invariant2("createContext" in exports_rehackt, 54);
  var context = undefined[contextKey];
  if (!context) {
    Object.defineProperty(undefined, contextKey, {
      value: context = undefined({}),
      enumerable: false,
      writable: false,
      configurable: true
    });
    context.displayName = "ApolloContext";
  }
  return context;
}

```

No wonder you’re having issues. The `React.createContext` symbol was completely replaced with `undefined`. In fact this looks to be the case wherever we are using `import * as React from 'rehackt'` inside Apollo Client. The implementation of `ApolloProvider` inside that `index-*.js` file is also littered with `undefined` for all `React.*` APIs.

@lenz by chance do you know of any issues between Bun and `rehackt`?

---

<div class="post-metadata">

**Author:** ![Tim-S](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/tim-s/32/5740_2.png) [@Tim-S](https://community.apollographql.com/u/Tim-S)\
**Post date:** [February 13, 2025, 12:31am UTC](https://community.apollographql.com/t/error-using-apolloprovider-cannot-read-properties-of-undefined-reading-symbol-apollo-context/8511/6 "2025-02-13T00:31:26Z")

</div>

Thanks! That was the lead I needed for further googling. Looks like there _is_ [an issue with bun+rehackt](https://github.com/oven-sh/bun/issues/12518) - I was able to work around the issue and get the page to load successfully w/ no errors by forcing a down-grade to rehackt 0.0.6

I have to step away for a bit, but will confirm that the client works/actually pulls data from the graphql server as expected later this evening.

---

<div class="post-metadata">

**Author:** ![Tim-S](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/tim-s/32/5740_2.png) [@Tim-S](https://community.apollographql.com/u/Tim-S)\
**Post date:** [February 13, 2025, 1:05am UTC](https://community.apollographql.com/t/error-using-apolloprovider-cannot-read-properties-of-undefined-reading-symbol-apollo-context/8511/7 "2025-02-13T01:05:20Z")

</div>

On rehackt 0.0.6 the provider does appear to be working as expected. I’m able to use `useQuery` elsewhere in the app with no problems.

Thanks again for the assistance!

---

<div class="post-metadata">

**Author:** ![lenz](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/lenz/32/4007_2.png) [@lenz](https://community.apollographql.com/u/lenz)\
**Post date:** [February 13, 2025, 9:01am UTC](https://community.apollographql.com/t/error-using-apolloprovider-cannot-read-properties-of-undefined-reading-symbol-apollo-context/8511/8 "2025-02-13T09:01:38Z")

</div>

I’m following up in that issue. Thanks for bringing this to our attention.
