npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@authjs-web3-providers/solana

v0.5.0

Published

AuthJS Web3 Providers for Solana

Downloads

6

Readme

@authjs-web3-providers/solana

AuthJS Web3 Provider for Solana blockchain authentication. This package enables users to sign in to your application using their Solana wallet.

Features

  • 🔐 Secure authentication using Solana wallet signatures
  • 🔄 Automatic session management
  • 🛠️ Easy integration with Next.js applications
  • 📦 Works with any Solana wallet (Phantom, Solflare, etc.)
  • 🔗 Supports both mainnet and devnet

Installation

pnpm add @authjs-web3-providers/solana @solana/wallet-adapter-base @solana/wallet-adapter-react @solana/wallet-adapter-wallets @solana/web3.js

Quick Start

  1. Configure your Next.js application with the Solana provider:
// pages/api/auth/[...nextauth].ts
import NextAuth from "next-auth"
import { SolanaProvider } from "@authjs-web3-providers/solana"
import { pgPool } from "@/tools/postgres/postgres"
import PostgresAdapter from "@auth/pg-adapter"

const adapter = PostgresAdapter(pgPool)

export default NextAuth({
  providers: [
    SolanaProvider({
      adapter,
      chainId: 101 // Solana Mainnet
    })
  ],
  adapter,
  session: {
    strategy: "jwt"
  }
})
  1. Create a sign-in page with wallet connection:
// pages/signin/solana.tsx
'use client';

import { useWallet } from '@solana/wallet-adapter-react';
import { signIn } from 'next-auth/react';
import { useRouter } from 'next/navigation';
import { useState } from 'react';

export default function SolanaSignIn() {
  const router = useRouter();
  const { publicKey, signMessage } = useWallet();
  const [isLoading, setIsLoading] = useState(false);

  const handleSignIn = async () => {
    if (!publicKey || !signMessage) return;

    try {
      setIsLoading(true);
      const nonce = await fetch('/api/auth/csrf').then(res => res.json());
      const message = `Sign in with Solana to the app.\n\nNonce: ${nonce}\nAddress: ${publicKey.toString()}`;
      
      const signature = await signMessage(new TextEncoder().encode(message));
      
      const result = await signIn('solana', {
        message,
        signature: Buffer.from(signature).toString('base64'),
        redirect: false,
      });

      if (result?.ok) {
        router.push('/');
      }
    } catch (error) {
      console.error('Sign in error:', error);
    } finally {
      setIsLoading(false);
    }
  };

  return (
    <div>
      <h1>Sign in with Solana</h1>
      <button
        onClick={handleSignIn}
        disabled={!publicKey || isLoading}
      >
        {isLoading ? 'Signing in...' : 'Sign in with Solana'}
      </button>
    </div>
  );
}
  1. Wrap your application with the Solana wallet provider:
// _app.tsx
import { WalletAdapterNetwork } from '@solana/wallet-adapter-base';
import { ConnectionProvider, WalletProvider } from '@solana/wallet-adapter-react';
import { PhantomWalletAdapter } from '@solana/wallet-adapter-wallets';
import { clusterApiUrl } from '@solana/web3.js';
import { SessionProvider } from 'next-auth/react';

const network = WalletAdapterNetwork.Devnet;
const endpoint = clusterApiUrl(network);
const wallets = [new PhantomWalletAdapter()];

export default function App({ Component, pageProps: { session, ...pageProps } }) {
  return (
    <SessionProvider session={session}>
      <ConnectionProvider endpoint={endpoint}>
        <WalletProvider wallets={wallets} autoConnect>
          <Component {...pageProps} />
        </WalletProvider>
      </ConnectionProvider>
    </SessionProvider>
  );
}

Configuration Options

The Solana provider accepts the following options:

interface SolanaProviderOptions {
  // Database adapter for storing user data
  adapter?: Adapter;
  
  // Session cookie configuration
  sessionCookie?: CookieOption;
  
  // Solana chain ID (default: 101 for mainnet)
  chainId?: number;
}

Security Considerations

  • Always verify the nonce in the signed message
  • Use HTTPS in production
  • Validate the wallet address and signature
  • Consider rate limiting for authentication attempts

Development

To run the development environment with hot reloading:

pnpm watch

License

MIT