Quick Start

Log in a user with Proma in four steps.

Step 1 — Create a client

import { PromaClient } from '@proma/sdk'

const proma = new PromaClient({
  clientId: 'proma_app_your_client_id',
  redirectUri: 'https://yourapp.com/auth/callback',
  scopes: ['profile', 'credits'],
})

Step 2 — Add a login button

// Redirect the user to Proma's login page
button.onclick = () => proma.login()

Step 3 — Handle the callback

On your /auth/callback page, exchange the code for tokens:

// Reads the code from the current URL automatically
const session = await proma.handleCallback()

// Fetch the logged-in user
const user = await proma.getUser()
console.log(user.email)

Step 4 — Check auth state on subsequent visits

// Returns null if not logged in, or a fresh session (auto-refreshes if expired)
const session = await proma.getSession()

if (session) {
  const user = await proma.getUser()
}

// Or just check the boolean:
const loggedIn = await proma.isAuthenticated()

Next steps