@authjs-web3-providers/siwe
v0.5.0
Published
AuthJS Web3 Providers for Ethereum using SIWE (Sign-In with Ethereum)
Maintainers
Readme
@authjs-web3-providers/siwe
Sign-In with Ethereum (SIWE) provider for Auth.js (NextAuth.js).
Features
- 🔐 Seamless integration with Auth.js
- 🌐 Web3 authentication using SIWE
- 📦 TypeScript support
- 🔄 Automatic session management
- 🛡️ Secure by default
Installation
npm install @authjs-web3-providers/siwe
# or
yarn add @authjs-web3-providers/siwe
# or
pnpm add @authjs-web3-providers/siweQuick Start
import { SiweProvider } from '@authjs-web3-providers/siwe';
import { NextAuthOptions } from 'next-auth';
export const authOptions: NextAuthOptions = {
providers: [
SiweProvider({
// Optional: Customize session cookie
sessionCookie: {
name: 'custom-session',
options: {
secure: process.env.NODE_ENV === 'production'
}
},
// Optional: Add database adapter
adapter: yourAdapter
})
],
session: {
strategy: 'jwt'
}
};Configuration Options
| Option | Type | Description | Default |
|--------|------|-------------|---------|
| sessionCookie | CookieOption | Customize session cookie settings | Uses NextAuth defaults |
| adapter | Adapter | Database adapter for user persistence | Optional |
API Reference
SiweProvider
interface Web3ProviderOptions {
sessionCookie?: CookieOption;
adapter?: Adapter;
}
function SiweProvider(options?: Web3ProviderOptions): Provider;Examples
Basic Usage with Default Settings
import { SiweProvider } from '@authjs-web3-providers/siwe';
import { NextAuthOptions } from 'next-auth';
export const authOptions: NextAuthOptions = {
providers: [
SiweProvider()
],
session: {
strategy: 'jwt'
}
};With Custom Session Cookie
import { SiweProvider } from '@authjs-web3-providers/siwe';
import { NextAuthOptions } from 'next-auth';
export const authOptions: NextAuthOptions = {
providers: [
SiweProvider({
sessionCookie: {
name: 'custom-session',
options: {
secure: process.env.NODE_ENV === 'production',
sameSite: 'lax'
}
}
})
],
session: {
strategy: 'jwt'
}
};Contributing
Contributions are welcome! Please see our Contributing Guide for details.
License
This package is licensed under the MIT License - see the LICENSE file for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Support
For support, please open an issue in the GitHub repository or contact us at [email protected].
