Skip to main content

Introduction

Midnight Auth is a TypeScript library for connecting React applications to the Midnight Network. It provides a simple, secure way to authenticate users, manage sessions, and sign zero-knowledge transactions through the Lace Midnight wallet.

What is Midnight?

Midnight is a data protection blockchain that uses zero-knowledge cryptography to enable private smart contracts. Unlike traditional blockchains where all data is public, Midnight allows developers to build applications that protect sensitive user information while maintaining verifiability.

Why Midnight Auth?

Connecting to Midnight wallets and managing authentication sessions requires boilerplate code that's repetitive across projects. Midnight Auth provides the infrastructure layer so you can focus on building your application.

Core Capabilities

🔐 Wallet Authentication - Connect to Lace Midnight wallet with session persistence and auto-reconnect.

📝 Transaction Signing - Sign and submit zero-knowledge transactions with a simple API.

⚡ Session Management - Automatic session handling with configurable timeouts and reconnection logic.

📘 TypeScript Native - Full type safety with comprehensive type definitions for all Midnight APIs.

Package Information

What's Included

Components:

  • MidnightAuthProvider - Authentication context provider
  • MidnightConnectButton - Pre-built wallet connection UI
  • MidnightWalletInfo - Display connected wallet information
  • ProtectedRoute - Protect routes requiring authentication

Hooks:

  • useMidnightAuth - Core authentication and wallet operations
  • useMidnightWallet - Access wallet state and account data
  • useMidnightSession - Session status and management

Requirements

Next Steps