nexlayer-sdk
v0.1.1
Published
JavaScript/TypeScript client SDK for Nexlayer — managed PostgreSQL, file storage, auth, and realtime over REST
Maintainers
Readme
@nexlayer/sdk
JavaScript/TypeScript client for Nexlayer — managed PostgreSQL, file storage, auth, and realtime in one SDK.
Install
npm install @nexlayer/sdkQuick Start
import { createClient } from '@nexlayer/sdk';
const nexlayer = createClient({ url: 'https://your-project.nexlayer.io' });
// --- Auth ---
const { user } = await nexlayer.auth.signUp({
email: '[email protected]',
password: 's3cret!',
});
await nexlayer.auth.signIn({ email: '[email protected]', password: 's3cret!' });
const me = await nexlayer.auth.getUser();
await nexlayer.auth.signOut();
// --- Database (PostgREST-style) ---
const { data: posts } = await nexlayer.from('posts').select('id, title');
await nexlayer.from('posts').insert({ title: 'Hello', body: 'World' });
await nexlayer.from('posts').eq('id', 1).update({ title: 'Updated' });
await nexlayer.from('posts').eq('id', 1).delete();
// Filters & pagination
const { data } = await nexlayer
.from('posts')
.select('*')
.eq('author_id', user.id)
.order('created_at', { ascending: false })
.limit(10);
// --- Storage ---
const bucket = nexlayer.storage.from('avatars');
await bucket.upload('pic.png', file, { contentType: 'image/png' });
const { data: files } = await bucket.list();
const { data: { publicUrl } } = bucket.getPublicUrl('pic.png');
// --- Realtime ---
nexlayer
.channel('room:lobby')
.on('postgres_changes', { event: 'INSERT', table: 'messages' }, (payload) => {
console.log('New message:', payload);
})
.subscribe();
// --- Edge Functions ---
const { data: result } = await nexlayer.functions.invoke('hello', {
body: { name: 'World' },
});License
MIT
