@ofins/client
v0.10.1
Published
A package that provides useful utilities for frontend web applications
Readme
@ofins/client
A personal npm package containing utilities and components for frontend development. Includes both framework-agnostic helpers and React-specific hooks/components.
Designed for rapid-use in your own projects.
Features
- Agnostic utilities: Functions and helpers usable in any frontend project.
- React framework support: Hooks and components for authentication, state management, and more.
- Modular structure: Import only what you need.
- TypeScript support: All exports are fully typed.
Installation
npm install @ofins/clientReact Framework
import { useLogin, AuthProvider } from "@ofins/client";Example: Authentication in React
import {
AuthProvider,
useLogin,
} from "@ofins/client/src/frameworks/react/auth";
function LoginForm() {
const login = useLogin({
onLogin: async ({ email, password }) => {
// Your login logic here
},
onSuccess: () => {
// Handle success
},
onError: (err) => {
// Handle error
},
});
return (
<form onSubmit={login.handleSubmit}>
<input
type="email"
value={login.credentials.email}
onChange={(e) => login.setEmail(e.target.value)}
/>
<input
type="password"
value={login.credentials.password}
onChange={(e) => login.setPassword(e.target.value)}
/>
<button type="submit" disabled={login.isLoading}>
Login
</button>
</form>
);
}Development
- Written in TypeScript
- Linting and formatting via ESLint and Prettier
- Build with
npm run build
License
ISC
