The `local-first-auth` library provides a client-side implementation of the Local First Auth specification, enabling web applications to integrate authentication without relying on backend servers, passwords, or third-party providers. Currently at version 2.2.1, it focuses on providing a lightweight, DID-based (Decentralized Identifier, specifically `did:key`) authentication flow where user profiles and cryptographic keys are generated and stored locally on the user's device. This approach is ideal for temporary or in-person community applications like meetups, social clubs, or game nights, offering a simple 3-step onboarding process. A key differentiator is its serverless nature and focus on local data storage, which simplifies development for specific use cases. However, users must be aware that clearing browser data will result in the loss of their account keys, making it unsuitable for applications requiring persistent or multi-device account access. The library offers both React components and vanilla JavaScript functions for integration, shipping with TypeScript types.
npm install local-first-authVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to integrate the `Onboarding` component into a React application, managing its visibility based on existing local-first authentication state and handling successful profile creation.
Advise users about data persistence limitations or explicitly design your application for temporary/one-time authentication scenarios where account recovery or multi-device access is not critical.
Do not use `local-first-auth` for applications requiring robust, persistent, or multi-device user accounts. For such use cases, traditional authentication systems are more appropriate. This library excels in specific local-first, in-person scenarios.
Ensure you are using ECMAScript Module (ESM) imports: `import { Onboarding } from 'local-first-auth/react'` and that your build tools (e.g., Webpack, Rollup) are configured to handle ESM properly.Install React in your project: `npm install react` (for React v18) or `npm install react@^19.0.0` (for React v19).