Sign-In With Solana is a standard for wallet-based authentication. The signIn method works identically whether you’re using web3.js or Kit - choose whichever architecture fits your project.
React
Vanilla TS
import { useWallet } from '@hermis/solana-headless-react';function SignInButton() { const { signIn } = useWallet(); const handleSignIn = async () => { try { const { account, signedMessage, signature } = await signIn({ domain: window.location.host, statement: 'Sign in to MyDApp', uri: window.location.origin, }); // Verify signature on your backend using: // - account.address (user's public key) // - signedMessage (the message that was signed) // - signature (the cryptographic signature) // Then create a session token or JWT console.log('Signed in:', account.address); } catch (error) { console.error('Sign in failed:', error); } }; return <button onClick={handleSignIn}>Sign In</button>;}
import { WalletAdapterManager } from '@hermis/solana-headless-core';const manager = new WalletAdapterManager();async function handleSignIn() { try { const { account, signedMessage, signature } = await manager.signIn({ domain: window.location.host, statement: 'Sign in to MyDApp', uri: window.location.origin, }); // Verify signature on your backend using: // - account.address (user's public key) // - signedMessage (the message that was signed) // - signature (the cryptographic signature) // Then create a session token or JWT console.log('Signed in:', account.address); } catch (error) { console.error('Sign in failed:', error); }}