I just published a small package I've been working on - ton-better-auth. It's a Better Auth plugin that lets users sign in with their TON wallet using TON Connect.
The idea came from needing this for a project and not finding a clean solution. It handles the
ton_proof verification on the backend - replay protection, signature validation, state-init parsing for different wallet versions, all that stuff.Basic setup looks like this:
npm install ton-better-auth
import { betterAuth } from "better-auth";
import { tonConnect } from "ton-better-auth";
export const auth = betterAuth({
plugins: [
tonConnect({ allowedDomains: ["your-app.com"] }),
],
});Works with @tonconnect/ui-react on the frontend and supports multi-wallet linking.
I also made AI skills for it:
npx skills add mhbdev/ton-better-auth
Let me know if you run into any issues or have feedback. Always happy to improve it.
Github - NPM Package - Skills