npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

sdk-supabase-machin

v1.1.0

Published

Supabase adapter for Machin SDK

Readme

@machin/sdk-supabase (sdk-supabase-machin)

Supabase adapter for sdk-core-machin. Provides Supabase backend implementation with Factory Pattern for efficient client sharing.

Installation

npm install sdk-core-machin sdk-supabase-machin @supabase/supabase-js

For React Native:

npm install @react-native-async-storage/async-storage react-native-url-polyfill

🚀 Quick Start (Recommended)

Using Factory Pattern (Efficient)

import { MachinSDK } from 'sdk-core-machin';
import { createSupabaseAdapters } from 'sdk-supabase-machin';
import AsyncStorage from '@react-native-async-storage/async-storage';

// Create all adapters with ONE shared Supabase client
const adapters = createSupabaseAdapters({
  supabaseUrl: process.env.SUPABASE_URL!,
  supabaseKey: process.env.SUPABASE_KEY!,
  storage: {
    async saveToken(session) {
      await AsyncStorage.setItem('session', JSON.stringify(session));
    },
    async deleteToken() {
      await AsyncStorage.removeItem('session');
    }
  },
  redirectUrl: 'myapp://password/new-password'
});

// Initialize SDK
MachinSDK.init(adapters);

// Use anywhere
const sdk = MachinSDK.getInstance();
await sdk.auth.sign_in('[email protected]', 'password');

Benefits:

  • ✅ Single Supabase client (more efficient)
  • ✅ One configuration point
  • ✅ Clean code
  • ✅ No credential repetition

Advanced Usage

Manual Adapter Creation

If you need more control:

import { createClient } from '@supabase/supabase-js';
import { AuthSupabaseAdapter } from 'sdk-supabase-machin';

// Create client manually
const supabaseClient = createClient(
  process.env.SUPABASE_URL!,
  process.env.SUPABASE_KEY!
);

// Create adapters with the same client
const authAdapter = new AuthSupabaseAdapter(supabaseClient, {
  storage: { ... },
  redirectUrl: 'myapp://password/new-password'
});

// When you add more domains:
const userAdapter = new UserSupabaseAdapter(supabaseClient);
const clientAdapter = new ClientSupabaseAdapter(supabaseClient);

MachinSDK.init({
  auth: authAdapter,
  user: userAdapter,
  client: clientAdapter
});

Direct Supabase Client Access

For operations not covered by the SDK:

import { createSupabaseClient } from 'sdk-supabase-machin';

const client = createSupabaseClient({
  supabaseUrl: process.env.SUPABASE_URL!,
  supabaseKey: process.env.SUPABASE_KEY!
});

// Use Supabase directly
const { data } = await client
  .from('custom_table')
  .select('*');

API Reference

createSupabaseAdapters(config)

Creates all Supabase adapters with a shared client.

Parameters:

interface SupabaseFactoryConfig {
  supabaseUrl: string;          // Your Supabase project URL
  supabaseKey: string;          // Your Supabase anon key
  storage?: SessionStorage;     // Optional session persistence
  redirectUrl?: string;         // Deep link for password reset
}

Returns:

interface SupabaseAdapters {
  auth: AuthSupabaseAdapter;
  // More adapters will be added as you implement them:
  // user: UserSupabaseAdapter;
  // client: ClientSupabaseAdapter;
  // shift: ShiftSupabaseAdapter;
}

createSupabaseClient(config)

Creates a standalone Supabase client for advanced use.

Parameters:

{
  supabaseUrl: string;
  supabaseKey: string;
}

Returns: SupabaseClient


Full Example (React Native)

// src/lib/sdk.ts
import { MachinSDK } from 'sdk-core-machin';
import { createSupabaseAdapters } from 'sdk-supabase-machin';
import AsyncStorage from '@react-native-async-storage/async-storage';
import 'react-native-url-polyfill/auto';

export const initSDK = () => {
  const adapters = createSupabaseAdapters({
    supabaseUrl: process.env.EXPO_PUBLIC_SUPABASE_URL!,
    supabaseKey: process.env.EXPO_PUBLIC_SUPABASE_ANON_KEY!,
    storage: {
      async saveToken(session) {
        await AsyncStorage.setItem('auth_session', JSON.stringify(session));
      },
      async deleteToken() {
        await AsyncStorage.removeItem('auth_session');
      }
    },
    redirectUrl: 'myapp://password/new-password'
  });

  MachinSDK.init(adapters);
};

export const getSDK = () => MachinSDK.getInstance();
// App.tsx
import { useEffect } from 'react';
import { initSDK } from './lib/sdk';

export default function App() {
  useEffect(() => {
    initSDK();
  }, []);

  return (
    // Your app components
  );
}
// LoginScreen.tsx
import { useState } from 'react';
import { getSDK } from '../lib/sdk';

export default function LoginScreen() {
  const [email, setEmail] = useState('');
  const [password, setPassword] = useState('');

  const handleLogin = async () => {
    const sdk = getSDK();
    const result = await sdk.auth.sign_in(email, password);
    
    if (result.error) {
      console.error(result.error.message);
    } else {
      console.log('Logged in!', result.data.user);
    }
  };

  return (
    // UI...
  );
}

Comparison

✅ Factory Pattern (Recommended)

const adapters = createSupabaseAdapters({ url, key, storage });
MachinSDK.init(adapters);

Pros:

  • Single Supabase client (efficient)
  • One configuration
  • Clean and simple

⚠️ Manual Creation

const client = createClient(url, key);
MachinSDK.init({
  auth: new AuthSupabaseAdapter(client, { storage }),
  user: new UserSupabaseAdapter(client),
  // ... more adapters
});

Pros:

  • More control
  • Can customize per adapter

Cons:

  • More verbose
  • Easy to forget to share client

Environment Variables

# .env
EXPO_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
EXPO_PUBLIC_SUPABASE_ANON_KEY=your-anon-key

License

MIT © Novexis Consulting