🚧 VeloxKit is pre-release software. APIs may change before v1.0. Get started →
Documentation
Packages
@velox/auth

@velox/auth

OAuth sign-in: opens the provider in the system browser, captures the redirect via a deep link, and stores tokens in the OS keychain.

Requires: a registered deep-link scheme (deeplink in velox.config.json) and the credentials capability.

Install

npm install @velox/auth

Usage

fetch is available globally (also importable from @velox/react).

import { createAuth } from '@velox/auth'
 
const auth = createAuth({
  redirect: 'myapp://auth',
  providers: {
    github: {
      authUrl: 'https://github.com/login/oauth/authorize',
      clientId: '…', scope: 'read:user',
      exchange: async (code) => (await fetch('/oauth/github', { method: 'POST', body: code })).json(),
    },
  },
})
 
const tokens = await auth.signIn('github')
const token  = await auth.getAccessToken('github')
await auth.signOut('github')