### Development Server Output Example
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/BUILD_AND_DEPLOYMENT.md
Example output when starting the development server, showing the Next.js version, local URL, and environment details.
```text
▲ Next.js 15.5.7
- Local: http://localhost:3000
- Environments: .env.local
Ready in 2.1s
```
--------------------------------
### Build and Start Production Server
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/README.md
Builds the Next.js application for production deployment and starts the production server. Refer to BUILD_AND_DEPLOYMENT.md for detailed setup instructions.
```bash
pnpm build # Build for production
pnpm start # Start production server
```
--------------------------------
### Self-Hosted Node.js Build and Start
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/BUILD_AND_DEPLOYMENT.md
Steps to build and start a Next.js application for self-hosting. This involves installing dependencies, building the project, and then starting the production server with necessary environment variables.
```bash
# 1. Build
pnpm install
pnpm build
# 2. Start
NODE_ENV=production NEXT_PUBLIC_PRIVY_APP_ID=... pnpm start
```
--------------------------------
### Production Build and Start Sequence
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/BUILD_AND_DEPLOYMENT.md
The sequence of commands to build the application for production and then start the production server.
```bash
pnpm build
pnpm start
```
--------------------------------
### Install and Deploy with Vercel CLI
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/BUILD_AND_DEPLOYMENT.md
Install the Vercel CLI globally and then run the deploy command in your project directory. Vercel offers automatic setup, builds on every push, automatic HTTPS, preview deployments for PRs, and environment variable management.
```bash
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel
```
--------------------------------
### Start Node.js Production Server
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/README.md
Build the application for production and start the Node.js server. Required environment variables must be set before starting.
```bash
pnpm build
NODE_ENV=production NEXT_PUBLIC_PRIVY_APP_ID=... pnpm start
```
--------------------------------
### Start Production Server
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/BUILD_AND_DEPLOYMENT.md
Start the optimized production server after building the application. This command runs 'pnpm start'.
```bash
pnpm start
```
--------------------------------
### Install Dependencies and Configure Environment
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/README.md
Installs project dependencies and sets up essential environment variables for Privy integration. Ensure you replace placeholders with your actual Privy App ID and Client ID.
```bash
# Install dependencies
pnpm install
# Create environment file
echo "NEXT_PUBLIC_PRIVY_APP_ID=your-app-id" > .env.local
echo "NEXT_PUBLIC_PRIVY_CLIENT_ID=your-client-id" >> .env.local
# Start development server
pnpm dev
```
--------------------------------
### Deploy with Vercel
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/README.md
Install the Vercel CLI and use the interactive command for deployment. This is the recommended deployment method.
```bash
npm install -g vercel
vercel # Interactive deployment
```
--------------------------------
### Production Build Output Example
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/BUILD_AND_DEPLOYMENT.md
Example output after a successful production build, indicating the Next.js version and the size/load characteristics of different routes.
```text
▲ Next.js 15.5.7
Route (app) Size First Load JS
┌ ○ / 42 kB ...
├ /_not-found ... ...
├ ○ /layout ... ...
└ ○ /page ... ...
○ (Static) automatically rendered as static HTML
```
--------------------------------
### Run Development Server
Source: https://github.com/privy-io/create-next-app/blob/main/README.md
Use these commands to start the Next.js development server. Open http://localhost:3000 in your browser to view the application.
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
--------------------------------
### Install Project Dependencies
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/BUILD_AND_DEPLOYMENT.md
Install project dependencies using pnpm, npm, or yarn. pnpm is recommended as specified in the package.json.
```bash
# Using pnpm (recommended per package.json)
pnpm install
```
```bash
# Or with npm
npm install
```
```bash
# Or with yarn
yarn install
```
--------------------------------
### useMfaEnrollment()
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/INDEX.md
Hook to launch the Multi-Factor Authentication (MFA) setup modal.
```APIDOC
## useMfaEnrollment()
### Description
Launches the user interface for setting up Multi-Factor Authentication (MFA).
### Methods
- `enrollMfa`: function - Initiates the MFA enrollment process.
```
--------------------------------
### Start Development Server
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/README.md
Use this command to run the Next.js development server. It enables hot reloading and TypeScript checking on save.
```bash
pnpm dev
```
--------------------------------
### GitHub Actions CI/CD Workflow
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/BUILD_AND_DEPLOYMENT.md
A GitHub Actions workflow to automate the build and deployment process on every push to the main branch. It includes setup, installation, linting, building, and deploying to Vercel.
```yaml
name: Build and Deploy
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'pnpm'
- run: pnpm install
- run: pnpm lint
- run: pnpm build
- name: Deploy to Vercel
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
run: vercel --prod
```
--------------------------------
### Ethereum Private Key Example
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/wallet-management.md
Provides an example of a valid hex-encoded, 0x-prefixed private key for importing an Ethereum wallet.
```typescript
// Valid input
"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
```
--------------------------------
### Solana Private Key Example
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/wallet-management.md
Provides an example of a valid Base58-encoded private key for importing a Solana wallet.
```typescript
// Valid input (Base58)
"5FHnedjThGVGvrQBGg56ws9j2UNvk3ozNW97DMNhhWWq7usrPFc"
```
--------------------------------
### Usage Example for ISection
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/TYPES_AND_INTERFACES.md
Illustrates how to instantiate an ISection object with properties like name, description, filepath, actions, and children.
```typescript
const sectionProps: ISection = {
name: "Create Wallet",
description: "Create a new embedded wallet",
filepath: "src/components/sections/create-wallet",
actions: availableActions,
children: ,
};
```
--------------------------------
### Environment Variables Setup
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/BUILD_AND_DEPLOYMENT.md
Create a .env.local file in the project root and populate it with your Privy application credentials. These are required for the application to connect to Privy services.
```bash
NEXT_PUBLIC_PRIVY_APP_ID=
NEXT_PUBLIC_PRIVY_CLIENT_ID=
NEXT_PUBLIC_PRIVY_SIGNER_ID= # Optional, for session signers
```
--------------------------------
### Complete Usage Example with Error Handling
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/custom-toast.md
Demonstrates how to use showSuccessToast and showErrorToast within an async function to provide user feedback on wallet creation operations.
```typescript
import { showSuccessToast, showErrorToast } from "@/components/ui/custom-toast";
async function handleWalletCreation() {
try {
const wallet = await createWallet({ createAdditional: true });
showSuccessToast("Wallet created successfully!");
} catch (error) {
showErrorToast(`Wallet creation failed: ${error.message}`);
}
}
```
--------------------------------
### FullScreenLoader Usage Example
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/UI_COMPONENTS.md
Demonstrates how to import and conditionally render the FullScreenLoader component in a React application, typically used when an SDK is not yet ready.
```typescript
import { FullScreenLoader } from "@/components/ui/fullscreen-loader";
function App() {
const { ready } = usePrivy();
if (!ready) return ;
return ;
}
```
--------------------------------
### Basic Section Usage with Actions
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/section.md
A simple example of the Section component used with only the required props: name, description, filepath, and an array of actions.
```typescript
{} },
{ name: "Do Another Thing", function: () => {} },
]}
/>
```
--------------------------------
### Configure PrivyProvider in Next.js
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/INDEX.md
Initialize the PrivyProvider in your `src/providers/providers.tsx` file. This setup includes embedded wallet creation logic and external wallet connectors for both Ethereum and Solana.
```typescript
{children}
```
--------------------------------
### Add and Configure Bundle Analyzer
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/BUILD_AND_DEPLOYMENT.md
Install the bundle analyzer as a development dependency and configure `next.config.js` to enable it. Run the build command with the `ANALYZE` environment variable set to true to generate the analysis.
```javascript
npm install --save-dev @next/bundle-analyzer
# Then in next.config.js
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
module.exports = withBundleAnalyzer(nextConfig)
# Run analysis
ANALYZE=true pnpm build
```
--------------------------------
### Create a Wallet Component Structure
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/create-wallet.md
Illustrates the component structure for creating a wallet, including hook setup for different wallet types, handler definitions, and action array construction for rendering UI elements.
```typescript
export default function CreateAWallet(): React.ReactElement {
// Hook setup (3 wallet creation hooks)
const { createWallet: createWalletEvm } = useCreateEvmWallet({...});
const { createWallet: createWalletSolana } = useSolanaWallets();
const { createWallet: createWalletExtendedChains } =
useCreateWalletExtendedChains();
// Handler definitions
const createWalletEvmHandler = async () => {...};
const createWalletSolanaHandler = async () => {...};
const createWalletExtendedChainHandler = (chain) => {...};
// Action array construction
const availableActions: IAction[] = [
{ name: "Create Ethereum wallet", function: createWalletEvmHandler },
{ name: "Create Solana wallet", function: createWalletSolanaHandler },
// ... extended chain actions
];
// Render Section with actions
return (
);
}
```
--------------------------------
### Usage Example for IAction
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/TYPES_AND_INTERFACES.md
Demonstrates how to create an array of IAction objects, specifying the name, function, and disabled status for each action.
```typescript
const actions: IAction[] = [
{
name: "Create Wallet",
function: handleCreateWallet,
disabled: !isReady,
},
];
```
--------------------------------
### Usage Example: Create a Wallet Section
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/section.md
Demonstrates how to use the Section component to create a wallet feature, including defining actions and passing them as props. Requires importing the Section component and a custom hook `useCreateWallet`.
```typescript
import Section from "@/components/reusables/section";
const CreateAWallet = () => {
const { createWallet } = useCreateWallet({
onSuccess: ({ wallet }) => {
console.log("Wallet created:", wallet);
},
});
const handleCreate = async () => {
await createWallet({ createAdditional: true });
};
const availableActions = [
{
name: "Create Ethereum wallet",
function: handleCreate,
disabled: false,
},
];
return (
{/* Optional form inputs or other content */}
);
};
```
--------------------------------
### Use MFA Enrollment Hook
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/mfa.md
Import and use the `useMfaEnrollment` hook to access the `showMfaEnrollmentModal` function. This hook is essential for initiating the MFA setup flow.
```typescript
const { showMfaEnrollmentModal } = useMfaEnrollment();
```
--------------------------------
### Development Commands for Next.js App
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/INDEX.md
Standard pnpm commands for managing the development lifecycle of your Next.js application, including starting the dev server, building for production, and running linters.
```bash
pnpm dev
```
```bash
pnpm build
```
```bash
pnpm start
```
```bash
pnpm lint
```
```bash
pnpm lint --fix
```
--------------------------------
### Add Session Signer Configuration
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/session-signers.md
Example of configuring and calling `addSessionSigners` to add a new session signer. Ensure the `NEXT_PUBLIC_PRIVY_SIGNER_ID` environment variable is set.
```typescript
await addSessionSigners({
address: selectedWallet.address,
signers: [
{
signerId: process.env.NEXT_PUBLIC_PRIVY_SIGNER_ID!, // Required env var
policyIds: [], // Empty for unrestricted signing
},
],
});
```
--------------------------------
### Setting Up .env.local for Environment Variables
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/BUILD_AND_DEPLOYMENT.md
Instructions to create and populate the .env.local file for setting environment variables, specifically addressing the 'NEXT_PUBLIC_PRIVY_APP_ID not defined' error. Remember to restart your development server after changes.
```bash
# Create .env.local
cp .env.example .env.local # or manually create
# Add variables
NEXT_PUBLIC_PRIVY_APP_ID=your-id-here
# Restart dev server
pnpm dev
```
--------------------------------
### Build and Run Docker Image
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/README.md
Build a Docker image for your application and run it, exposing the application port. Ensure environment variables are passed during runtime.
```bash
docker build -t privy-demo .
docker run -p 3000:3000 \
-e NEXT_PUBLIC_PRIVY_APP_ID=... \
-e NEXT_PUBLIC_PRIVY_CLIENT_ID=... \
privy-demo
```
--------------------------------
### Build and Run Docker Container
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/BUILD_AND_DEPLOYMENT.md
Build a Docker image from the Dockerfile and then run the container, mapping port 3000 from the container to the host. Ensure to set necessary environment variables like NEXT_PUBLIC_PRIVY_APP_ID.
```bash
docker build -t privy-demo .
docker run -p 3000:3000 -e NEXT_PUBLIC_PRIVY_APP_ID=... privy-demo
```
--------------------------------
### Remove Session Signer API Call
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/session-signers.md
Example of calling `removeSessionSigners` to remove a session signer associated with a specific wallet address.
```typescript
await removeSessionSigners({
address: selectedWallet.address,
});
```
--------------------------------
### CustomToast Integration with react-toastify
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/UI_COMPONENTS.md
Shows how to integrate the CustomToast component with the react-toastify library for displaying notifications. Ensure react-toastify is installed and configured.
```typescript
import { toast } from "react-toastify";
import { CustomToast } from "@/components/ui/custom-toast";
tost(, {
position: "top-center",
autoClose: 5000,
// ... other options
});
```
--------------------------------
### linkCrossAppAccount Method Usage
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/link-accounts.md
Example of how to use the `linkCrossAppAccount` method, requiring the target Privy app ID. This is used for cross-application account linking.
```typescript
linkCrossAppAccount({
appId: "cm04asygd041fmry9zmcyn5o5", // Demo app ID
});
```
--------------------------------
### Root Layout Usage of Providers Component
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/providers.md
Example of how to use the Providers component in the root layout of a Next.js application to wrap all child components.
```typescript
// src/app/layout.tsx
import Providers from "@/providers/providers";
export default function RootLayout({ children }) {
return (
{children}
);
}
```
--------------------------------
### Set Up Privy Environment Variables
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/README.md
Configure required and optional environment variables for Privy integration. Ensure these are set in your .env file or build environment.
```bash
# Required
NEXT_PUBLIC_PRIVY_APP_ID=your-app-id-from-dashboard
NEXT_PUBLIC_PRIVY_CLIENT_ID=your-client-id-from-dashboard
# Optional (for session signers)
NEXT_PUBLIC_PRIVY_SIGNER_ID=your-signer-id
```
--------------------------------
### Handle Wallet Operations with useWallets
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/README.md
Shows how to use the `useWallets` hook to display a list of connected wallets. This hook requires Privy context to be initialized.
```typescript
import { useWallets } from "@privy-io/react-auth";
function WalletComponent() {
const { wallets } = useWallets();
if (wallets.length === 0) return
No wallets
;
return
{wallets.map(w =>
{w.address}
)}
;
}
```
--------------------------------
### Build for Production
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/BUILD_AND_DEPLOYMENT.md
Generate an optimized production build using pnpm build. This command runs 'next build --turbopack' to compile, optimize, and bundle the application.
```bash
pnpm build
```
--------------------------------
### Configure PrivyProvider in React
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/README.md
Integrate the PrivyProvider component into your application's root to enable Privy authentication. This setup includes configuration for embedded and external wallets.
```typescript
{children}
```
--------------------------------
### Use Privy Hook for Authentication
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/README.md
Demonstrates how to use the `usePrivy` hook to check authentication status and initiate login. Ensure Privy context is set up in your application.
```typescript
import { usePrivy } from "@privy-io/react-auth";
function MyComponent() {
const { authenticated, user, login } = usePrivy();
if (!authenticated) return ;
return
Welcome, {user?.email?.address}
;
}
```
--------------------------------
### Header Component Usage Example
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/UI_COMPONENTS.md
Demonstrates how to import and use the Header component within a React Layout function. This snippet shows the Header placed at the top of the layout.
```typescript
import { Header } from "@/components/ui/header";
function Layout() {
return (
{/* Content */}
);
}
```
--------------------------------
### Usage Example for UnlinkAccounts Component
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/unlink-accounts.md
Demonstrates how to import and use the UnlinkAccounts component within a React application. The component handles the UI and logic for unlinking user accounts.
```typescript
import UnlinkAccounts from "@/components/sections/unlink-accounts";
function Dashboard() {
return (
);
}
// User workflow:
// 1. View all linked accounts dynamically rendered as buttons
// 2. Click "Unlink Email (...)" to remove email
// 3. Click "Unlink Google (...)" to remove Google OAuth
// 4. Success toast confirms unlink
```
--------------------------------
### WalletActions Component Structure
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/wallet-actions.md
Defines the structure of the WalletActions React component, including hook setup, state management, wallet aggregation, type checks, and action definitions.
```typescript
export default function WalletActions(): React.ReactElement {
// Hook setup
const { signMessage: signMessageEvm } = useSignMessageEvm();
const { wallets: walletsEvm } = useWallets();
// ... more hooks ...
// State
const [selectedWallet, setSelectedWallet] = useState(null);
// Wallet aggregation
const allWallets: WalletInfo[] = useMemo(() => { /* ... */ }, [walletsEvm, walletsSolana]);
// Type checks
const isEvmWallet = selectedWallet?.type === "ethereum";
const isSolanaWallet = selectedWallet?.type === "solana";
// Handler methods (8 methods)
// Action array construction
const availableActions: IAction[] = [
{ name: "Sign message (EVM)", function: handleSignMessageEvm, disabled: !isEvmWallet },
// ... more actions ...
];
// Render Section with dropdown and actions
return (
);
}
```
--------------------------------
### Use Fund Wallet Hook (EVM and Solana)
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/HOOKS_AND_UTILITIES.md
Initiates the wallet funding flow using `useFundWalletEvm` or `useFundWalletSolana`. Specify the wallet address, amount, and asset (e.g., 'USDC', 'native-currency', or an ERC-20 contract address).
```typescript
// EVM
const { fundWallet } = useFundWalletEvm();
fundWallet(walletAddress, {
amount: "1",
asset: "USDC", // or "native-currency" or {erc20: "0x..." }
});
// Solana
const { fundWallet } = useFundWalletSolana();
fundWallet(walletAddress, {
amount: "1",
asset: "USDC", // or "native-currency"
});
```
--------------------------------
### useSolanaWallets()
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/INDEX.md
Hook for listing and creating Solana wallets.
```APIDOC
## useSolanaWallets()
### Description
Manages Solana wallets, allowing users to list existing ones and create new ones.
### Methods
- `wallets`: array - An array of Solana wallet objects.
- `createWallet`: function - Function to create a new Solana wallet.
```
--------------------------------
### Get Handler for Link Method
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/link-accounts.md
Maps a specific link method to its corresponding handler function. This is useful for dynamic dispatching of actions based on the chosen link method.
```typescript
const getHandlerForMethod = (method: Method): (() => void | Promise);
```
--------------------------------
### useImportWallet()
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/INDEX.md
Hook for importing Ethereum or Solana wallets using a private key.
```APIDOC
## useImportWallet()
### Description
Enables the import of existing Ethereum or Solana wallets by providing their private keys.
### Methods
- `importWallet`: function - Function to import a wallet. Accepts `privateKey` and optionally `chain` (for Solana import).
```
--------------------------------
### Dockerfile for Node.js Application
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/BUILD_AND_DEPLOYMENT.md
A Dockerfile to containerize a Node.js application using pnpm for package management. It installs dependencies, builds the application, exposes port 3000, and sets the production environment.
```dockerfile
FROM node:18-alpine
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN npm install -g pnpm && pnpm install --frozen-lockfile
COPY . .
RUN pnpm build
EXPOSE 3000
ENV NODE_ENV production
CMD ["pnpm", "start"]
```
--------------------------------
### Set Privy Environment Variables
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/INDEX.md
Configure these environment variables in your .env file to initialize Privy. NEXT_PUBLIC_PRIVY_APP_ID and NEXT_PUBLIC_PRIVY_CLIENT_ID are required. NEXT_PUBLIC_PRIVY_SIGNER_ID is optional for session signers.
```bash
NEXT_PUBLIC_PRIVY_APP_ID=your-app-id-here
NEXT_PUBLIC_PRIVY_CLIENT_ID=your-client-client-id-here
```
```bash
NEXT_PUBLIC_PRIVY_SIGNER_ID=your-signer-id # For session signers feature
```
--------------------------------
### useImportWallet() (Solana)
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/INDEX.md
Hook for importing Solana wallets via private key.
```APIDOC
## useImportWallet() (Solana)
### Description
Allows importing Solana wallets using their private keys.
### Methods
- `importWallet`: function - Function to import a Solana wallet. Requires the `privateKey`.
```
--------------------------------
### Root Layout HTML Structure
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/UI_COMPONENTS.md
Illustrates the basic HTML structure for the root layout, including the ``, ``, and `Providers` wrapper. It sets up global font variables and applies antialiased styling.
```html
{children}
```
--------------------------------
### useFundWallet
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/HOOKS_AND_UTILITIES.md
Initiates the wallet funding flow for both EVM and Solana using `useFundWalletEvm` and `useFundWalletSolana` hooks respectively. Allows funding with specified assets.
```APIDOC
## useFundWallet
### Description
Initiates wallet funding flow.
### Source
`@privy-io/react-auth` and `@privy-io/react-auth/solana`
### Usage
```typescript
// EVM
const { fundWallet } = useFundWalletEvm();
fundWallet(walletAddress, {
amount: "1",
asset: "USDC", // or "native-currency" or {erc20: "0x..." }
});
// Solana
const { fundWallet } = useFundWalletSolana();
fundWallet(walletAddress, {
amount: "1",
asset: "USDC", // or "native-currency"
});
```
```
--------------------------------
### useWallets()
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/INDEX.md
Hook for listing and managing Ethereum wallets associated with the user.
```APIDOC
## useWallets()
### Description
Provides a list of Ethereum wallets for the authenticated user.
### Methods
- `wallets`: array - An array of wallet objects.
```
--------------------------------
### useCreateWallet (EVM)
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/TYPES_AND_INTERFACES.md
Provides a function to create a new EVM-compatible wallet for the user.
```APIDOC
## useCreateWallet (EVM)
### Description
Provides a function to create a new EVM-compatible wallet for the user.
### Methods
- `createWallet(options: { createAdditional: boolean })`: Creates a new wallet. `createAdditional` determines if additional wallets should be created.
### Return Value
- `createWallet` (function): The function to create a wallet.
- `isLoading` (boolean): Indicates if the wallet creation process is in progress.
```
--------------------------------
### Create Solana Wallet Handler
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/create-wallet.md
Handles the creation of a new Solana embedded wallet. It invokes `createWalletSolana` with `createAdditional: true` and provides user feedback for success or failure.
```typescript
const createWalletSolanaHandler = async (): Promise;
```
--------------------------------
### Netlify Build Configuration
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/BUILD_AND_DEPLOYMENT.md
Configuration for Netlify to build and deploy a Next.js application. Specifies the build command, function directory, and production environment variables.
```toml
[build]
command = "pnpm build"
functions = ".netlify/functions"
[context.production.environment]
NEXT_PUBLIC_PRIVY_APP_ID = "your-app-id"
```
--------------------------------
### useCreateWallet()
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/INDEX.md
Hook for creating new embedded Ethereum wallets or wallets for extended chains.
```APIDOC
## useCreateWallet()
### Description
Allows the creation of new embedded Ethereum wallets or wallets for a variety of extended chains.
### Methods
- `createWallet`: function - Function to create a new wallet. Accepts an optional `chain` parameter for extended chains.
```
--------------------------------
### Use Solana Wallets Hook
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/create-wallet.md
Hook for creating a Solana wallet. Use this when you need to create a Solana wallet. The `createAdditional` option allows for multiple wallets.
```typescript
const { createWallet: createWalletSolana } = useSolanaWallets();
```
```typescript
await createWalletSolana({
createAdditional: true,
});
```
--------------------------------
### Wallet State Initialization
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/wallet-management.md
Initializes state variables for the selected wallet and private key using React's useState hook.
```typescript
const [selectedWallet, setSelectedWallet] = useState(null);
const [privateKey, setPrivateKey] = useState("");
```
--------------------------------
### Create Solana Wallet
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/create-wallet.md
Use the `useSolanaWallets` hook to create a Solana wallet. This hook also supports creating additional wallets.
```APIDOC
## Create Solana Wallet
### Description
Creates a Solana wallet. Supports creating additional wallets.
### Method
`createWallet` (from `useSolanaWallets` hook)
### Usage
```typescript
await createWalletSolana({
createAdditional: true,
});
```
```
--------------------------------
### Create Extended Chain Wallet Handler
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/create-wallet.md
Handles the creation of a new wallet for extended chain networks like Cosmos, Stellar, and Sui. It requires a `chain` parameter to specify the network and provides feedback on the operation's outcome.
```typescript
const createWalletExtendedChainHandler = (
chain: SupportedExtendedChains
): Promise;
```
--------------------------------
### Use Import Wallet (Solana) Hook
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/HOOKS_AND_UTILITIES.md
Imports external Solana wallets via private key. Ensure the private key is Base58-encoded.
```typescript
const { importWallet } = useImportWalletSolana();
await importWallet({
privateKey: "base58...", // Base58-encoded private key
});
```
--------------------------------
### Access and Create Solana Wallets
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/HOOKS_AND_UTILITIES.md
Provides access to user's Solana wallets and methods to create new embedded Solana wallets or import existing ones via private key.
```typescript
const { wallets, createWallet, isLoading } = useSolanaWallets();
await createWallet({ createAdditional: true });
```
--------------------------------
### Create EVM Wallet
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/api-reference/create-wallet.md
Use the `useCreateEvmWallet` hook to create an Ethereum Virtual Machine (EVM) compatible wallet. You can optionally allow users to create additional wallets.
```APIDOC
## Create EVM Wallet
### Description
Creates an EVM-compatible wallet. Allows for the creation of additional wallets if `createAdditional` is set to true.
### Method
`createWalletEvm` (from `useCreateEvmWallet` hook)
### Parameters
- `onSuccess` (function) - Callback fired when wallet creation succeeds.
- `onError` (function) - Callback fired when wallet creation fails.
### Usage
```typescript
await createWalletEvm({
createAdditional: true,
});
```
```
--------------------------------
### useFundWallet()
Source: https://github.com/privy-io/create-next-app/blob/main/_autodocs/INDEX.md
Hook that presents a modal for funding wallets via card, exchange, or other wallets (EVM & Solana).
```APIDOC
## useFundWallet()
### Description
Opens a modal that allows users to fund their wallets using various methods like credit cards, exchanges, or by transferring from another wallet. Supports EVM and Solana.
### Methods
- `fundWallet`: function - Opens the funding modal.
```