Skip to content

Setting up the Alchemy Accounts Provider

Once you have followed the Signer Setup Guide, set up and configure the Alchemy Accounts Provider in your project.

You can do this by wrapping the top level component (e.g. _layout.tsx in Expo or App.tsx in Bare React Native) in your app with the AlchemyAccountsProvider component from the @account-kit/react-native package.

Here's an example of how to do this:

_layout.tsx (Expo)
import "react-native-get-random-values"; // Shims for the crypto module
import React from "react";
import { alchemy, sepolia } from "@account-kit/infra";
import {
  AlchemyAccountProvider,
  createConfig,
} from "@account-kit/react-native";
import { QueryClient } from "@tanstack/react-query";
 
const queryClient = new QueryClient();
 
const config = createConfig({
  chain: sepolia,
  transport: alchemy({
    apiKey: "YOUR_ALCHEMY_API_KEY",
  }),
  signerConnection: {
    apiKey: "YOUR_ALCHEMY_API_KEY",
  },
  sessionConfig: {
    expirationTimeMs: 1000 * 60 * 60 * 24, // <-- Adjust the session expiration time as needed (currently 24 hours)
  },
});
 
export default function App() {
  return (
    <AlchemyAccountProvider config={config} queryClient={queryClient}>
      {/* The rest of your app here... */}
    </AlchemyAccountProvider>
  );
}

Next Steps

Now that you have set up the Alchemy Accounts Provider, you can follow the Authentication Guides to learn how to authenticate users.