@sawa-dev/sdk
v1.0.10
Published
💍 Backend API for Sawa - A marriage-focused relationship platform for Egypt & the Middle East. Built with Next.js 16+, MongoDB, Socket.io, and intelligent matching algorithms.
Maintainers
Readme
@sawa-dev/sdk
TypeScript SDK for Sawa Backend API - A marriage-focused relationship platform for Egypt & the Middle East.
Installation
npm install @sawa-dev/sdk @tanstack/react-query axiosQuick Start
1. Setup React Query Client
// app/providers.tsx
'use client';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { useState } from 'react';
export function Providers({ children }: { children: React.ReactNode }) {
const [queryClient] = useState(() => new QueryClient());
return (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
);
}2. Configure API Base URL
// lib/api-config.ts
export const API_CONFIG = {
baseURL: process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3000',
};3. Use SDK Hooks
// components/auth/LoginForm.tsx
import { useLoginMutation } from '@sawa-dev/sdk';
export function LoginForm() {
const loginMutation = useLoginMutation();
const handleLogin = async (email: string, password: string) => {
try {
const result = await loginMutation.mutateAsync({
data: { email, password },
});
if (result.success) {
localStorage.setItem('token', result.data.token);
// Redirect or update auth state
}
} catch (error) {
console.error('Login failed:', error);
}
};
return (
<form
onSubmit={e => {
e.preventDefault();
const formData = new FormData(e.target);
handleLogin(
formData.get('email') as string,
formData.get('password') as string
);
}}
>
<input name="email" type="email" required />
<input name="password" type="password" required />
<button type="submit" disabled={loginMutation.isPending}>
{loginMutation.isPending ? 'Logging in...' : 'Login'}
</button>
</form>
);
}Available Hooks
Authentication
useLoginMutation()- User loginuseSignupMutation()- User registration
Profile
useGetProfile()- Get current user profileuseUpdateProfileMutation()- Update user profileuseCompleteProfileMutation()- Complete profile setup
Discovery
useGetDiscoveryFeed()- Get discovery feeduseLikeUserMutation()- Like a user
Matches
useGetMatches()- Get user matches
Verification
useSubmitVerificationMutation()- Submit ID verification
Configuration
The SDK automatically handles:
- Authentication token management
- Request/response interceptors
- Error handling
- TypeScript types
License
MIT
