New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@supabase/gotrue-js

Package Overview
Dependencies
Maintainers
9
Versions
316
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@supabase/gotrue-js

Official client library for Supabase Auth

2.62.2
Source
npm
Version published
Weekly downloads
141K
23.75%
Maintainers
9
Weekly downloads
 
Created

What is @supabase/gotrue-js?

@supabase/gotrue-js is a JavaScript client library for Supabase's GoTrue server, which provides user authentication and management functionalities. It allows developers to handle user sign-ups, logins, password recovery, and other authentication-related tasks.

What are @supabase/gotrue-js's main functionalities?

User Sign-Up

This feature allows you to sign up a new user with an email and password. The code sample demonstrates how to initialize the GoTrueClient and use the signUp method to create a new user.

const { GoTrueClient } = require('@supabase/gotrue-js');
const auth = new GoTrueClient({
  url: 'https://your-supabase-url.supabase.co/auth/v1',
  headers: { 'apikey': 'your-api-key' }
});

async function signUp(email, password) {
  const { user, error } = await auth.signUp({ email, password });
  if (error) console.error('Error signing up:', error);
  else console.log('User signed up:', user);
}

signUp('user@example.com', 'password123');

User Login

This feature allows you to log in an existing user with an email and password. The code sample demonstrates how to use the signIn method to authenticate a user.

const { GoTrueClient } = require('@supabase/gotrue-js');
const auth = new GoTrueClient({
  url: 'https://your-supabase-url.supabase.co/auth/v1',
  headers: { 'apikey': 'your-api-key' }
});

async function login(email, password) {
  const { user, error } = await auth.signIn({ email, password });
  if (error) console.error('Error logging in:', error);
  else console.log('User logged in:', user);
}

login('user@example.com', 'password123');

Password Recovery

This feature allows you to send a password recovery email to a user. The code sample demonstrates how to use the resetPasswordForEmail method to initiate the password recovery process.

const { GoTrueClient } = require('@supabase/gotrue-js');
const auth = new GoTrueClient({
  url: 'https://your-supabase-url.supabase.co/auth/v1',
  headers: { 'apikey': 'your-api-key' }
});

async function recoverPassword(email) {
  const { data, error } = await auth.api.resetPasswordForEmail(email);
  if (error) console.error('Error sending password recovery email:', error);
  else console.log('Password recovery email sent:', data);
}

recoverPassword('user@example.com');

Other packages similar to @supabase/gotrue-js

Keywords

auth

FAQs

Package last updated on 19 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts