Component
Sign In With Solana
Authenticates a Solana wallet with a server-issued SIWS challenge, Wallet Standard sign-in, signature verification, and an HTTP-only session.
Preview
Sign in with Solana
Connect your wallet to continue securely.
Installation
terminal
$npx shadcn@latest add https://uxdotsol.xyz/r/sign-in-with-solana.jsonUsage
usage
import { ConnectWalletBtn } from "@/components/uxdotsol/components/connect-wallet-btn";import { SignInWithSolana } from "@/components/uxdotsol/components/sign-in-with-solana";import { SolanaProvider } from "@/components/uxdotsol/components/solana-provider"; export default function AccountPage() { return ( <SolanaProvider> <ConnectWalletBtn /> <SignInWithSolana onSuccess={(session) => { console.log("Authenticated wallet", session.address); }} /> </SolanaProvider> );}.env.local
SOLANA_AUTH_SECRET=generate_at_least_32_random_charactersSOLANA_AUTH_ORIGIN=https://example.comSOLANA_AUTH_CHAIN_ID=mainnetSOLANA_AUTH_STATEMENT=Sign in to ExampleProps / Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| endpoint | string | '/api/auth/solana' | Next.js route that creates challenges, verifies SIWS output, and manages the session cookie. |
| accountEndpoint | string | '/api/wallet-account' | Endpoint used to load the connected address's actual SOL balance. |
| cluster | 'mainnet-beta' | 'devnet' | 'testnet' | 'mainnet-beta' | Solana cluster used for the balance request and derived network label. |
| className | string | '' | Optional classes applied to the outer authentication card. |
| walletLabel | string | wallet adapter name | Optional label override. By default the connected wallet adapter name is used. |
| networkLabel | string | derived from cluster | Optional network-label override. Pass an empty string to hide it. |
| balance | string | fetched after connection | Optional formatted balance override. Otherwise the connected address balance is fetched. |
| fiatValue | string | undefined | Optional formatted fiat equivalent displayed beside the balance. |
| onSuccess | (session: { address: string; expiresAt: string }) => void | undefined | Called after the server verifies the signature and creates a session. |
| onError | (error: Error) => void | undefined | Called when challenge creation, wallet approval, verification, or sign-out fails. |

