UX.SOL

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.json

Usage

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_characters
SOLANA_AUTH_ORIGIN=https://example.com
SOLANA_AUTH_CHAIN_ID=mainnet
SOLANA_AUTH_STATEMENT=Sign in to Example

Props / Arguments

NameTypeDefaultDescription
endpointstring'/api/auth/solana'Next.js route that creates challenges, verifies SIWS output, and manages the session cookie.
accountEndpointstring'/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.
classNamestring''Optional classes applied to the outer authentication card.
walletLabelstringwallet adapter nameOptional label override. By default the connected wallet adapter name is used.
networkLabelstringderived from clusterOptional network-label override. Pass an empty string to hide it.
balancestringfetched after connectionOptional formatted balance override. Otherwise the connected address balance is fetched.
fiatValuestringundefinedOptional formatted fiat equivalent displayed beside the balance.
onSuccess(session: { address: string; expiresAt: string }) => voidundefinedCalled after the server verifies the signature and creates a session.
onError(error: Error) => voidundefinedCalled when challenge creation, wallet approval, verification, or sign-out fails.