Authentication via messengers instead of SMS — no per-message costs. Every authenticated user becomes reachable for notifications by phone number through the same bots. The system picks the right messenger automatically; you control the priority.
Import ESM from your Auth Cloud (/esm/) or use the UMD script. Verify app_id in JWT on the server after login.
'use client';
import { useEffect } from 'react';
import { init, login, on, off } from 'https://id.antirius.com/esm/index.js';
init({
appId: 'YOUR_APP_ID',
baseUrl: 'https://id.antirius.com',
poll_type: 'full',
});
export function LoginBlock() {
useEffect(() => {
const onSuccess = (payload) => {
console.log('JWT:', payload.token);
};
on('success', onSuccess);
return () => off('success', onSuccess);
}, []);
return (
<button type="button" onClick={() => login({ mode: 'popup' })}>
Sign in
</button>
);
}
// ESM с вашего Auth Cloud (без npm): https://id.antirius.com/esm/index.js
// Либо UMD <script> — см. вкладку «JS SDK».// app/auth/callback/page.js
'use client';
import { useEffect } from 'react';
import { useSearchParams } from 'next/navigation';
import { init, completeRedirectLogin, parseCallbackUrl } from 'https://id.antirius.com/esm/index.js';
init({
appId: 'YOUR_APP_ID',
baseUrl: 'https://id.antirius.com',
poll_type: 'full',
});
export default function AuthCallbackPage() {
const searchParams = useSearchParams();
useEffect(() => {
const params = parseCallbackUrl(searchParams);
if (!params.sessionId) return;
completeRedirectLogin()
.then(() => { window.location.href = '/'; })
.catch(console.error);
}, [searchParams]);
return <p>Signing in…</p>;
}
// Hosted redirect login:
// window.location.href = `https://id.antirius.com/login/YOUR_APP_ID?return_url=` + encodeURIComponent(window.location.origin + '/auth/callback');