> For the complete documentation index, see [llms.txt](https://docs.cometh.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cometh.io/integrations/react-hooks/connectprovider.md).

# ConnectProvider

## Description

The `ConnectProvider` component in TypeScript React sets up a context provider for managing the ConnectSmartAccount related state and functionality.

## Parameters

* **apiKey** : Cometh Connect public api key. This can be retrieved from the Cometh dashboard
* **networksConfig**: \
  \- **bundlerUrl**: The URL of the Cometh bundler. This can be retrieved from the Cometh 4337 docs and dashboard.\
  \- **paymasterUrl** - optional: The paymaster API key. This can be retrieved from the Cometh dashboard\
  \- **chain**: Your required viem chain.\
  \- **rpcUrl** - optional
* **signer** - optional: A signer from an [external auth provider ](/advanced/other-signers-auth-providers.md)(metamask...) that will control the account

## Example

<pre class="language-typescript"><code class="lang-typescript"><strong>"use client";
</strong>
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { Inter } from "next/font/google";
import "./lib/ui/globals.css";

import { ConnectProvider } from "@cometh/connect-react-hooks";
import { arbitrumSepolia } from "viem/chains";

const queryClient = new QueryClient();

const inter = Inter({
    subsets: ["latin"],
});

const apiKey = process.env.NEXT_PUBLIC_COMETH_API_KEY;
const bundlerUrl = process.env.NEXT_PUBLIC_4337_BUNDLER_URL;
const paymasterUrl = process.env.NEXT_PUBLIC_4337_PAYMASTER_URL;
const rpcUrl = "https://arbitrum-sepolia.blockpi.network/v1/rpc/public";

const networksConfig = [
    {
        chain: arbitrumSepolia,
        bundlerUrl,
        paymasterUrl,
        rpcUrl
    },
];


export default function RootLayout({
    children,
}: {
    children: React.ReactNode;
}) {
    return (
        &#x3C;html lang="en">
            &#x3C;QueryClientProvider client={queryClient}>
                &#x3C;ConnectProvider
                    config={{
                        apiKey,
                        networksConfig
                    }}
                    queryClient={queryClient}
                >
                    &#x3C;body className={inter.className}>{children}&#x3C;/body>
                &#x3C;/ConnectProvider>
            &#x3C;/QueryClientProvider>
        &#x3C;/html>
    );
}
</code></pre>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.cometh.io/integrations/react-hooks/connectprovider.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
