Skip to content

Init Authentication

Codedraw client comes with an out-of-the box integration to Kinde. Here is a simple example of how to initialize the authentication service with Kinde.

typescript
import type { 
  Authentication,
  AuthenticationOptions
} from '@coderpunktech/codedraw-client'

const options: AuthenticationOptions = {
  audience: 'your-configured-audience',
  client_id: 'KINDE_CLIENT_ID',
  org_code: 'KINDE_ORG_ID',
  domain: 'AUTHENTICATION_DOMAIN',
  is_dangerously_use_local_storage: false,
  on_callback_redirect_path: '/auth/callback', // or your configured callback path
  register_redirect_path: '/register', // or your configured register path
  on_redirect_callback: (user: any, appState: AppState) => {
    // you can add your custom redirect logic heres
    if (appState?.redirectTo) {
      window.location.href = decodeURIComponent(appState.redirectTo) || '/'
    }
  },
}
const authentication = await sdkClient.Authentication.init(options)