This recipe covers adding Phantom Connect to a Next.js + React app. Use their Browser SDK for
non-React web apps and the React Native SDK
for mobile apps.
Prerequisites
Create a Phantom Portal app, configure allowed domains and redirect URLs, and copy the App ID.Step-by-step (Next.js + React)
Install the React SDK
Use the React SDK for Next.js + React.
Install dependencies
Install dependencies
Optional starter template
Optional starter template
Add PhantomProvider (App Router or Pages Router)
Wrap your root layout so Phantom Connect can manage auth and wallet state.
Put your App ID in
config.appId (see appId: "your-app-id" in the examples)
and set the redirect URL you configured.- App Router
- Pages Router
Create a client-side provider component, then wrap it in
app/layout.tsx.app/providers.tsx
app/providers.tsx
app/layout.tsx
app/layout.tsx
Connect a user
Use the built-in modal or ConnectButton to trigger the Phantom flow.
Connect with the modal
Connect with the modal
ConnectButton (ready-to-use)
ConnectButton (ready-to-use)
Theme the Phantom ConnectUI
Use theming to customize
the modal UI.