Utilities API Reference ​
Utility functions and helpers available in Flowfull Clients.
Authentication Utilities ​
isAuthenticated ​
Check if a user is authenticated.
typescript
function isAuthenticated(user: User | null): booleanExample:
typescript
import { isAuthenticated } from '@pubflow/react';
const { user } = useAuth();
if (isAuthenticated(user)) {
console.log('User is authenticated');
}hasUserType ​
Check if a user has a specific user type.
typescript
function hasUserType(user: User | null, types: string | string[]): booleanExample:
typescript
import { hasUserType } from '@pubflow/react';
const { user } = useAuth();
if (hasUserType(user, ['admin', 'superadmin'])) {
console.log('User is admin');
}Storage Utilities ​
BrowserStorageAdapter ​
Browser localStorage adapter for React.
typescript
class BrowserStorageAdapter implements StorageAdapter {
constructor(prefix?: string);
getItem(key: string): Promise<string | null>;
setItem(key: string, value: string): Promise<void>;
removeItem(key: string): Promise<void>;
clear(): Promise<void>;
}Example:
typescript
import { BrowserStorageAdapter } from '@pubflow/react';
const storage = new BrowserStorageAdapter('myapp_');
await storage.setItem('key', 'value');
const value = await storage.getItem('key');SecureStorageAdapter ​
Secure storage adapter for React Native (Expo SecureStore with AsyncStorage fallback).
typescript
class SecureStorageAdapter implements StorageAdapter {
constructor(useSecureStorage?: boolean, prefix?: string);
getItem(key: string): Promise<string | null>;
setItem(key: string, value: string): Promise<void>;
removeItem(key: string): Promise<void>;
clear(): Promise<void>;
}Example:
typescript
import { SecureStorageAdapter } from '@pubflow/react-native';
const storage = new SecureStorageAdapter(true, 'myapp_');
await storage.setItem('session_id', 'abc123');API Utilities ​
ApiClient ​
Low-level HTTP client with automatic authentication.
typescript
class ApiClient {
constructor(config: ApiClientConfig);
get<T>(path: string, options?: RequestOptions): Promise<T>;
post<T>(path: string, data?: any, options?: RequestOptions): Promise<T>;
put<T>(path: string, data?: any, options?: RequestOptions): Promise<T>;
patch<T>(path: string, data?: any, options?: RequestOptions): Promise<T>;
delete<T>(path: string, options?: RequestOptions): Promise<T>;
}Example:
typescript
import { ApiClient, BrowserStorageAdapter } from '@pubflow/core';
const client = new ApiClient({
baseUrl: 'https://api.example.com',
storage: new BrowserStorageAdapter()
});
const users = await client.get('/api/users');BridgeApiService ​
High-level Bridge API service for entity operations.
typescript
class BridgeApiService<T extends EntityData> {
constructor(apiClient: ApiClient, config: EntityConfig);
getList(params?: QueryParams): Promise<PaginatedResponse<T>>;
getById(id: string, params?: QueryParams): Promise<T>;
search(params: SearchParams): Promise<PaginatedResponse<T>>;
create(data: Partial<T>): Promise<T>;
update(id: string, data: Partial<T>): Promise<T>;
delete(id: string): Promise<void>;
}Example:
typescript
import { BridgeApiService, ApiClient } from '@pubflow/core';
const service = new BridgeApiService(apiClient, {
endpoint: 'users'
});
const users = await service.getList({ page: 1, limit: 20 });Next.js Utilities ​
withPubflow ​
API route middleware for Next.js.
typescript
function withPubflow(
handler: (req, res, api, auth) => Promise<void>,
instanceId?: string
): (req, res) => Promise<void>Example:
typescript
import { withPubflow } from '@pubflow/nextjs';
export default withPubflow(async (req, res, api, auth) => {
const users = await api.get('/bridge/users');
res.json(users);
});withPubflowAuth ​
Authenticated API route middleware for Next.js.
typescript
function withPubflowAuth(
handler: (req, res, api, auth, user) => Promise<void>,
options?: { instanceId?: string; allowedTypes?: string[] }
): (req, res) => Promise<void>Example:
typescript
import { withPubflowAuth } from '@pubflow/nextjs';
export default withPubflowAuth(
async (req, res, api, auth, user) => {
res.json({ user });
},
{ allowedTypes: ['admin'] }
);withPubflowSSR ​
SSR helper for Next.js pages.
typescript
function withPubflowSSR(
getServerSideProps: (context, api, auth) => Promise<GetServerSidePropsResult>
): GetServerSidePropsExample:
typescript
import { withPubflowSSR } from '@pubflow/nextjs';
export const getServerSideProps = withPubflowSSR(async (context, api, auth) => {
const users = await api.get('/bridge/users');
return { props: { users } };
});Next Steps ​
- Hooks API - Hooks reference
- Components API - Components reference
- Types API - TypeScript types reference