Back to Developers

Guide

Authentication Guide

Integrate Nexbic authentication into your application. Supports email/password, OAuth 2.0, SSO, and social login providers.

Implementation

Sign Up

Create a new user account with email and password. Nexbic handles hashing, session creation, and email verification.

TypeScript SDK typescript
const { user, session } = await nexbic.auth.signUp({
  email: "user@example.com",
  password: "securepassword",
  name: "Jane Doe"
});

// Session is automatically created
console.log(session.id); // "nxb_ses_..."
curl bash
curl -X POST https://api.nexbic.dev/v1/auth/signup \
  -H "Content-Type: application/json" \
  -H "X-API-Key: nxb_sk_..." \
  -d '{
    "email": "user@example.com",
    "password": "securepassword",
    "name": "Jane Doe"
  }'
Response json
{
  "user": {
    "id": "usr_1",
    "email": "user@example.com",
    "name": "Jane Doe",
    "email_verified": false
  },
  "session": {
    "id": "nxb_ses_...",
    "expires_at": "2026-06-19T00:00:00Z"
  }
}

Implementation

Sign In

Authenticate existing users with email and password. Returns a session token for subsequent requests.

TypeScript SDK typescript
const { user, session } = await nexbic.auth.signIn({
  email: "user@example.com",
  password: "securepassword"
});

// Store the session token
localStorage.setItem("nexbic_session", session.id);
curl bash
curl -X POST https://api.nexbic.dev/v1/auth/login \
  -H "Content-Type: application/json" \
  -H "X-API-Key: nxb_sk_..." \
  -d '{
    "email": "user@example.com",
    "password": "securepassword"
  }'

Implementation

Session Management

Manage user sessions with refresh tokens, validation, and revocation.

TypeScript SDK typescript
// Validate the current session
const { valid, user } = await nexbic.auth.validateSession(sessionId);
if (!valid) {
  // Redirect to login
}

// Refresh an expiring session
const { session } = await nexbic.auth.refreshSession(refreshToken);

// Sign out (revoke session)
await nexbic.auth.signOut(sessionId);

Implementation

OAuth 2.0 & Social Login

Support Google, GitHub, Apple, and any OAuth 2.0 / OIDC provider with a single unified API.

TypeScript SDK typescript
// Initiate OAuth flow
const { url } = await nexbic.auth.oauth.init({
  provider: "google",
  redirectUri: "https://yourapp.com/auth/callback"
});

// Redirect user to provider
window.location.href = url;

// Handle callback
const { user, session } = await nexbic.auth.oauth.callback({
  provider: "google",
  code: "oauth_code_from_provider"
});
curl bash
curl -X POST https://api.nexbic.dev/v1/auth/oauth/google \
  -H "Content-Type: application/json" \
  -H "X-API-Key: nxb_sk_..." \
  -d '{
    "redirect_uri": "https://yourapp.com/auth/callback"
  }'

Authentication is just the start

Explore wallet integration, webhooks, and more in the Nexbic developer docs.