Management API Reference

Configuration

Configure Openfort Kit

In this guide, we will show you how to use the Openfort Kit configuration to customize the look and feel of the Openfort login screen, configure your signer and more.

To learn more about the provider configuration, go to the provider configuration page.

This is a full example of how to use the OpenfortKitProvider with password authentication and a retro theme, using beamTestnet and polygonAmoy chains.


_88
import React from 'react';
_88
_88
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
_88
import { AuthProvider, OpenfortKitProvider, RecoveryMethod, getDefaultConfig } from '@openfort/openfort-kit';
_88
import { beamTestnet, polygonAmoy } from 'viem/chains';
_88
import { WagmiProvider, createConfig } from 'wagmi';
_88
import CustomLogo from './CustomLogo';
_88
_88
const config = createConfig(
_88
getDefaultConfig({
_88
appName: 'OpenfortKit Next.js demo',
_88
chains: [beamTestnet, polygonAmoy],
_88
_88
walletConnectProjectId: process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID!,
_88
})
_88
);
_88
_88
const queryClient = new QueryClient();
_88
_88
export const Web3Provider = ({ children }: { children: React.ReactNode }) => {
_88
return (
_88
<WagmiProvider config={config}>
_88
<QueryClientProvider client={queryClient}>
_88
<OpenfortKitProvider
_88
_88
// Set the publishable key of your OpenfortKit account. This field is required.
_88
publishableKey={process.env.NEXT_PUBLIC_OPENFORT_PUBLIC_KEY!}
_88
_88
// Set the wallet configuration. In this example, we will be using the embedded signer.
_88
walletConfig={{
_88
createEmbeddedSigner: true,
_88
_88
embeddedSignerConfiguration: {
_88
shieldPublishableKey: process.env.NEXT_PUBLIC_SHIELD_API_KEY!,
_88
_88
// Set the recovery method you want to use, in this case we will use the automatic recovery method
_88
recoveryMethod: RecoveryMethod.AUTOMATIC,
_88
_88
// Set the encryption key endpoint to encrypt the recovery data
_88
createEncryptedSessionEndpoint: '/api/protected-create-encrypted-session',
_88
_88
// You can set a policy id to sponsor the gas fees for your users
_88
ethereumProviderPolicyId: process.env.NEXT_PUBLIC_POLICY_ID,
_88
}
_88
}}
_88
_88
// This is the callback that will be called when the user connects or disconnects
_88
onConnect={(params) => {
_88
console.log('onConnect', params);
_88
}}
_88
onDisconnect={() => {
_88
console.log('onDisconnect');
_88
}}
_88
_88
options={{
_88
// You can customize the logo of your app
_88
logo: (<CustomLogo />),
_88
_88
// Set the auth providers you want to use
_88
authProviders: [
_88
AuthProvider.GUEST,
_88
AuthProvider.EMAIL,
_88
AuthProvider.GOOGLE,
_88
AuthProvider.TWITTER,
_88
AuthProvider.FACEBOOK,
_88
AuthProvider.WALLET,
_88
],
_88
_88
// Set the chain id you want to use, by default it will use the first chain
_88
initialChainId: polygonAmoy.id,
_88
_88
// Skip the email verification, useful for testing
_88
skipEmailVerification: true,
_88
_88
// Other useful options
_88
overlayBlur: 2.5,
_88
hideTooltips: true,
_88
}}
_88
_88
// Set the theme of the OpenfortKit
_88
theme="retro"
_88
>
_88
{children}
_88
</OpenfortKitProvider>
_88
</QueryClientProvider>
_88
</WagmiProvider >
_88
);
_88
};

OpenfortKitButton#

The button component that will allow your users to connect to Openfort.

To learn more about the OpenfortKitButton component, go to the button configuration page.


_10
import { OpenfortKitButton } from '@openfort/openfort-kit';
_10
_10
function App() {
_10
return (
_10
<div>
_10
<OpenfortKitButton />
_10
</div>
_10
);
_10
};