0
0
Supabasecloud~5 mins

JavaScript client installation in Supabase

Choose your learning style9 modes available
Introduction

You need the JavaScript client to connect your app to Supabase services easily.

When building a web app that needs to store or fetch data from Supabase.
When you want to add user login and authentication using Supabase.
When you want to listen to real-time updates from your database in a web app.
When you want to use Supabase storage to upload or download files from your JavaScript app.
Syntax
Supabase
npm install @supabase/supabase-js
This command installs the official Supabase JavaScript client library.
You run this in your project folder using a terminal or command prompt.
Examples
Installs the Supabase client for a Node.js or frontend JavaScript project.
Supabase
npm install @supabase/supabase-js
Alternative install command if you use Yarn package manager.
Supabase
yarn add @supabase/supabase-js
Alternative install command if you use pnpm package manager.
Supabase
pnpm add @supabase/supabase-js
Sample Program

This example shows how to install the client and create a Supabase client instance in your JavaScript code.

Supabase
// After installation, you can import and use it in your JavaScript code:
import { createClient } from '@supabase/supabase-js'

const supabaseUrl = 'https://xyzcompany.supabase.co'
const supabaseKey = 'public-anonymous-key'
const supabase = createClient(supabaseUrl, supabaseKey)

console.log('Supabase client created:', supabase !== null)
OutputSuccess
Important Notes

Make sure to replace supabaseUrl and supabaseKey with your actual project values.

Keep your keys safe and do not expose your secret keys in frontend code.

Summary

Install the Supabase JavaScript client with npm install @supabase/supabase-js.

Use the client to connect your app to Supabase services easily.

Remember to keep your keys secure and use environment variables when possible.