Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
@supabase/supabase-js
Advanced tools
@supabase/supabase-js is a JavaScript client library for interacting with Supabase, an open-source Firebase alternative. It allows developers to perform a variety of database operations, authentication, and real-time subscriptions with ease.
Database Operations
This feature allows you to perform CRUD operations on your database. The code sample demonstrates how to fetch data from a table using the Supabase client.
const { createClient } = require('@supabase/supabase-js');
const supabase = createClient('https://your-project.supabase.co', 'public-anon-key');
async function fetchData() {
let { data, error } = await supabase
.from('your_table')
.select('*');
if (error) console.error(error);
else console.log(data);
}
fetchData();
Authentication
This feature allows you to manage user authentication, including sign-up, sign-in, and sign-out. The code sample demonstrates how to sign up a new user.
const { createClient } = require('@supabase/supabase-js');
const supabase = createClient('https://your-project.supabase.co', 'public-anon-key');
async function signUp() {
let { user, error } = await supabase.auth.signUp({
email: 'example@example.com',
password: 'example-password'
});
if (error) console.error(error);
else console.log(user);
}
signUp();
Real-time Subscriptions
This feature allows you to subscribe to real-time changes in your database. The code sample demonstrates how to listen for new rows being inserted into a table.
const { createClient } = require('@supabase/supabase-js');
const supabase = createClient('https://your-project.supabase.co', 'public-anon-key');
supabase
.from('your_table')
.on('INSERT', payload => {
console.log('New row added!', payload);
})
.subscribe();
Firebase is a comprehensive app development platform by Google that offers a variety of tools including Firestore for database operations, Firebase Auth for authentication, and Firebase Realtime Database for real-time data synchronization. Compared to @supabase/supabase-js, Firebase offers a more extensive suite of services but is not open-source.
Hasura is an open-source engine that provides instant GraphQL APIs on your data. It supports real-time subscriptions and integrates well with existing databases. Compared to @supabase/supabase-js, Hasura focuses on GraphQL APIs and offers more advanced querying capabilities.
Parse is an open-source backend framework that provides a variety of features including a database, user authentication, and real-time notifications. It is similar to @supabase/supabase-js in its open-source nature and feature set but has a different architecture and community support.
supabase-js
- Isomorphic JavaScript Client for Supabase.First of all, you need to install the library:
npm install @supabase/supabase-js
Then you're able to import the library and establish the connection with the database:
import { createClient } from '@supabase/supabase-js'
// Create a single supabase client for interacting with your database
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
You can use plain <script>
s to import supabase-js from CDNs, like:
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
or even:
<script src="https://unpkg.com/@supabase/supabase-js@2"></script>
Then you can use it from a global supabase
variable:
<script>
const { createClient } = supabase
const _supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
console.log('Supabase Instance: ', _supabase)
// ...
</script>
You can use <script type="module">
to import supabase-js from CDNs, like:
<script type="module">
import { createClient } from 'https://cdn.jsdelivr.net/npm/@supabase/supabase-js/+esm'
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
console.log('Supabase Instance: ', supabase)
// ...
</script>
You can use supabase-js in the Deno runtime via JSR:
import { createClient } from 'jsr:@supabase/supabase-js@2'
fetch
implementationsupabase-js
uses the cross-fetch
library to make HTTP requests, but an alternative fetch
implementation can be provided as an option. This is most useful in environments where cross-fetch
is not compatible, for instance Cloudflare Workers:
import { createClient } from '@supabase/supabase-js'
// Provide a custom `fetch` implementation as an option
const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key', {
global: {
fetch: (...args) => fetch(...args),
},
})
We are building the features of Firebase using enterprise-grade, open source products. We support existing communities wherever possible, and if the products don’t exist we build them and open source them ourselves. Thanks to these sponsors who are making the OSS ecosystem better for everyone.
FAQs
Isomorphic Javascript client for Supabase
The npm package @supabase/supabase-js receives a total of 737,898 weekly downloads. As such, @supabase/supabase-js popularity was classified as popular.
We found that @supabase/supabase-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 13 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.