react-fastkit
Note: This package is under active development.
react-fastkit is a fast, opinionated toolkit for React, providing both UI components and utility functions to speed up your workflow.
Features
- UI Components: Plug-and-play components like
Button, Layout, and more.
- Utilities: Useful helpers such as
formatDate and isEmail for common tasks.
- API Helpers: Effortless API calls with built-in token and backend origin management.
Installation
Install via npm:
import { callApi, setBackendOrigin,setToken } from 'react-fastkit';
React.useEffect(() => {
setToken('1234567890');
setBackendOrigin('https://jsonplaceholder.typicode.com');
}, []);
const handleCallApi = async () => {
setError(null);
setUsers([]);
try {
// Fetch users from JSONPlaceholder
const res = await callApi('/users', {}, false); // publicCall = true
const data = await res.json();
setUsers(data);
} catch (err) {
setError(err.message || 'Unknown error');
}
};