Skip to main content

TokenDeliveryMode

Package: @nauth-toolkit/client Type: Type Alias

Type alias for token delivery modes. Determines how tokens are exchanged between client and server.

import { TokenDeliveryMode } from '@nauth-toolkit/client';

Values

ValueDescriptionUse Case
'cookies'Tokens stored in HTTP-only cookies by backendWeb applications
'json'Tokens returned in response body, stored client-sideMobile/native apps

Example

const client = new NAuthClient({
baseUrl: 'https://api.example.com/auth',
tokenDelivery: 'cookies', // or 'json'
onSessionExpired: () => {},
});

Token Delivery Details

Cookies Mode

  • Tokens stored in HTTP-only cookies (server-managed)
  • Requires withCredentials: true in requests
  • CSRF protection required
  • Most secure for web browsers

JSON Mode

  • Tokens returned in response body
  • Stored in provided storage adapter
  • Sent via Authorization: Bearer header
  • Required for mobile/native apps
Hybrid Backend

"Hybrid" is a backend deployment pattern, not a frontend mode. When your backend supports both web and mobile, it exposes separate endpoints. The frontend chooses ONE mode based on the platform.

Used By