JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1056570
  • Score
    100M100P100Q210471F
  • License MIT

Lovable Cloud Auth JS

Package Exports

  • @lovable.dev/cloud-auth-js
  • @lovable.dev/cloud-auth-js/dist/index.cjs
  • @lovable.dev/cloud-auth-js/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@lovable.dev/cloud-auth-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@lovable.dev/cloud-auth-js

OAuth authentication library for Lovable projects using Supabase.

Installation

npm install @lovable.dev/cloud-auth-js

Usage

import { createLovableAuth } from "@lovable.dev/cloud-auth-js";
import { supabase } from "./supabase/client";

const lovableAuth = createLovableAuth();

// Sign in with OAuth
const result = await lovableAuth.signInWithOAuth("google");

if (result.redirected) {
  // Page is redirecting to OAuth provider
  return;
}

if (result.error) {
  console.error("Sign in failed:", result.error.message);
  return;
}

await supabase.auth.setSession(result.tokens);

API

createLovableAuth(config?)

Creates a Lovable auth instance.

Config options:

Option Type Default Description
oauthBrokerUrl string "/~oauth/initiate" OAuth broker initiate URL
supportedOAuthOrigins string[] ["https://oauth.lovable.app"] Allowed origins for OAuth postMessage

signInWithOAuth(provider, options?)

Initiates OAuth sign-in flow.

Parameters:

Parameter Type Description
provider "google" | "apple" OAuth provider
options.redirect_uri string Custom redirect URI (defaults to window.location.origin)
options.extraParams Record<string, string> Additional params to send to the OAuth broker

Returns: Promise<SignInWithOAuthResult>

Types

interface OAuthTokens {
  access_token: string;
  refresh_token: string;
}

interface LovableAuthConfig {
  oauthBrokerUrl?: string;
  supportedOAuthOrigins?: string[];
}

interface SignInWithOAuthOptions {
  redirect_uri?: string;
  extraParams?: Record<string, string>;
}

type SignInWithOAuthResult =
  | { tokens: OAuthTokens; error: null; redirected?: false }
  | { tokens?: undefined; error: Error; redirected?: false }
  | { tokens?: undefined; error: null; redirected: true };

License

MIT