UNPKG

lightning-auth-and-payment

Version:

Lightning Network authentication and payment processing library for modern web applications

72 lines (52 loc) โ€ข 1.69 kB
# โšก Next.js Plugin Example This example demonstrates how to use the Lightning Auth & Payment Next.js plugin for automatic route generation. ## ๐Ÿš€ Quick Start 1. **Install dependencies:** ```bash npm install ``` 2. **Run the development server:** ```bash npm run dev:lightning ``` 3. **Open your browser:** ``` https://localhost:3443 ``` ## ๐Ÿ“ What's Generated The plugin automatically creates: - **API Routes**: `/api/auth/*`, `/api/user` - **Development Server**: `scripts/dev-server.mjs` - **Environment**: `.env.local` - **Components**: Example Lightning login component ## ๐Ÿ”ง Configuration The plugin is configured in `next.config.js`: ```javascript const { withLightning } = require('lightning-auth-and-payment'); module.exports = withLightning({ autoGenerateRoutes: true, database: 'memory', storage: 'memory', btcpay: false, development: true, })({ // Your Next.js config }); ``` ## ๐ŸŽฏ Usage The generated routes work automatically: - **Authentication**: `GET /api/auth/lnurl` - Generate LNURL - **Callback**: `GET /api/auth/callback` - Handle wallet response - **Status**: `GET /api/auth/status` - Check authentication status - **Logout**: `POST /api/auth/logout` - Logout user - **User**: `GET /api/user` - Get user data ## ๐Ÿงช Testing 1. **Start the server**: `npm run dev:lightning` 2. **Open**: `https://localhost:3443` 3. **Click**: "Login with Lightning" 4. **Use**: Alby browser extension or any Lightning wallet ## ๐Ÿ“š Documentation For more information, see: - [Next.js Plugin Documentation](../../NEXTJS_PLUGIN.md) - [Quick Start Guide](../../QUICK_START.md) - [AI Setup Guide](../../AI_SETUP_GUIDE.md)