better-near-auth is a plugin for the Better Auth library, enabling 'Sign in with NEAR' (SIWN) functionality for web3 applications. It abstracts the complexities of interacting with the NEAR Protocol's authentication mechanisms, allowing developers to integrate NEAR login flows into their existing Better Auth setups. The library currently stands at version 0.5.2 and shows an active development cadence with regular patch and minor releases, indicated by recent updates addressing bug fixes and introducing new features like single-step authentication and improved wallet selection logic. Key differentiators include its tight integration with Better Auth, support for modern NEAR authentication patterns (including `signMessage`), and handling of wallet connection and account resolution within the authentication flow.
npm install better-near-authVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize Better Auth with the BetterNearAuthPlugin and then initiate a 'Sign in with NEAR' flow. It configures the NEAR network parameters and calls `signIn.near()`.
Ensure your integration exclusively uses the `better-near-auth` plugin methods (e.g., `signIn.near()`) and does not rely on internals of `fastintear`.
Upgrade to version 0.5.1 or newer. If the issue persists, ensure that the wallet selection process is correctly initiated before or during the `signIn.near()` call, possibly by explicitly connecting a wallet first if your UI flow requires it.
Test your authentication flow thoroughly with various NEAR wallets after upgrading to v0.5.0 to ensure compatibility with the new single-step flow. Report issues if specific wallets do not function as expected.
Ensure your development environment uses pnpm for installing `better-near-auth`'s dependencies to avoid potential issues related to package resolution or conflicting lockfiles.
Ensure the wallet selection UI is correctly presented to the user before or during the `signIn.near()` call. Upgrade to `better-near-auth@0.5.1` or newer, which includes fixes for this specific scenario.
Verify that `new BetterNearAuthPlugin(...)` is included in the `plugins` array during the `better-auth.init()` call. Also, ensure `betterAuth` is the correct instance returned from `init()` or `useAuth()`.
Handle this error gracefully in your application's UI, informing the user that the sign-in process was canceled. Provide options for them to retry authentication.