> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hermis.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> Implementing authentication with Solana wallets

## Overview

Solana wallets can be used for authentication through message signing. This enables passwordless, blockchain-based authentication for your dApps.

## Sign-In With Solana (SIWS)

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.

<Tabs>
  <Tab title="React">
    ```typescript theme={null}
    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>;
    }
    ```
  </Tab>

  <Tab title="Vanilla TS">
    ```typescript theme={null}
    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);
      }
    }
    ```
  </Tab>
</Tabs>

## What's Next?

<CardGroup cols={2}>
  <Card title="Sign Message" icon="signature" href="/cookbook/sign-message">
    Message signing examples
  </Card>

  <Card title="Connect Wallet" icon="plug" href="/cookbook/connect-wallet">
    Wallet connection guide
  </Card>
</CardGroup>
