Skip to main content
CoreBase makes it easy to handle user accounts. You can sign users up, log them in, and manage their sessions without complex code.
CoreBase handles sessions automatically, so users stay logged in even if they refresh the page.

Sign Up

Create a new account for a user.
const { data, error } = await corebase.auth.signUp({
  email: 'user@example.com',
  password: 'securePassword123',
  name: 'John Doe'
});

if (error) {
  console.error('Signup failed:', error);
} else {
  console.log('Welcome!', data.user);
}

Sign In

Log in an existing user.
const { data, error } = await corebase.auth.signIn({
  email: 'user@example.com',
  password: 'securePassword123'
});

if (error) {
  console.error('Login failed:', error);
} else {
  console.log('Logged in successfully:', data.user);
}

Get Current User

Check who is currently logged in.
const { data, error } = await corebase.auth.getUser();

if (data) {
  console.log('Current user:', data.user);
}

Sign Out

Log out the current user securely.
await corebase.auth.signOut();

Sign In with a Provider (OAuth)

CoreBase also supports Google and GitHub sign-in. Unlike the methods above, this is a redirect flow, not a promise you await directly — the gateway completes the exchange with the provider and sends the user back to your app.
1

Redirect to the provider

Send the browser to the OAuth URL, passing your project’s ID.
window.location.href = corebase.auth.getOAuthUrl('google', projectId);
// or 'github'
2

Read the tokens on your success page

CoreBase redirects back to your configured success URL with the session in the query string.
const params = new URLSearchParams(window.location.search);

corebase.auth.setSessionFromTokens({
  access_token: params.get('access_token')!,
  refresh_token: params.get('refresh_token') ?? undefined,
  user: { id: params.get('user_id')!, email: '' },
});
Configure your Google/GitHub client ID and secret for the project first, via corebase.auth.updateAuthConfig(projectId, { google_client_id, google_client_secret }).

Refreshing a Session

Sessions refresh automatically in most cases. If you need to do it manually:
const { data, error } = await corebase.auth.refreshSession();