https://github.com/jhuntdev/blest-react
A React / React Native client for BLEST (Batch-able, Lightweight, Encrypted State Transfer), an improved communication protocol for web APIs which leverages JSON, supports request batching by default, and provides a modern alternative to REST.
https://github.com/jhuntdev/blest-react
api blest client react react-native reactjs
Last synced: 3 months ago
JSON representation
A React / React Native client for BLEST (Batch-able, Lightweight, Encrypted State Transfer), an improved communication protocol for web APIs which leverages JSON, supports request batching by default, and provides a modern alternative to REST.
- Host: GitHub
- URL: https://github.com/jhuntdev/blest-react
- Owner: jhuntdev
- License: mit
- Created: 2023-06-11T21:16:54.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2025-01-08T10:11:05.000Z (6 months ago)
- Last Synced: 2025-03-22T15:48:29.417Z (4 months ago)
- Topics: api, blest, client, react, react-native, reactjs
- Language: TypeScript
- Homepage:
- Size: 66.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BLEST React
A React client for BLEST (Batch-able, Lightweight, Encrypted State Transfer), an improved communication protocol for web APIs which leverages JSON, supports request batching by default, and provides a modern alternative to REST.
To learn more about BLEST, please visit the website: https://blest.jhunt.dev
## Features
- Built on JSON - Reduce parsing time and overhead
- Request Batching - Save bandwidth and reduce load times
- Compact Payloads - Save even more bandwidth
- Single Endpoint - Reduce complexity and facilitate introspection
- Fully Encrypted - Improve data privacy## Installation
Install BLEST React from npm
With npm:
```bash
npm install --save blest-react
```
or using yarn:
```bash
yarn add blest-react
```## Usage
Wrap your app (or just part of it) with `BlestProvider`.
```javascript
import React from 'react'
import { BlestProvider } from 'blest-react'const blestOptions = {
maxBatchSize: 25,
bufferDelay: 10,
httpHeaders: { Authorization: 'Bearer token' }
}const App = () => {
return (
{/* Your app here */}
)
}
```Use the `useBlestRequest` hook to perform passive requests on mount and when parameters change.
```javascript
import { useBlestRequest } from 'blest-react'const MyComponent = () => {
const { data, loading, error } = useBlestRequest(
'listItems', // route
{ limit: 24 }, // body
{ select: ['edges', ['pageInfo', ['endCursor', 'hasNextPage']]] } // options
)return (
// Your component here
)
}
```Use the `useBlestLazyRequest` hook to generate a request function you can call when needed.
```javascript
import { useBlestLazyRequest } from 'blest-react'const MyForm = () => {
const [submitForm, { data, loading, error }] = useBlestLazyRequest(
'submitForm', // route
{ select: ['success'] } // options
)const handleSubmit = (values) => {
submitForm(values)
}return (
// Your form here
)
}
```## License
This project is licensed under the [MIT License](LICENSE).