Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
http-react
Advanced tools
Http React is a React hooks library for data fetching. It's built on top of the native Fetch
API.
With one hook call, you get all the information about a request that you can use to build UIs that are consistent and performant:
import useFetch from 'http-react'
// This is the default fetcher.
const fetcher = (url, config) => fetch(url, config)
export default function App() {
const { data, loading, error, responseTime } = useFetch('/api/user-info', {
refresh: '30 sec',
fetcher
})
if (loading) return <p>Loading</p>
if (error) return <p>An error ocurred</p>
return (
<div>
<h2>Welcome, {data.name}</h2>
<small>Profile loaded in {responseTime} miliseconds</small>
</div>
)
}
It also works with Next.js' server functions:
// actions.ts
'use server'
import { actionData } from 'http-react'
export async function getData({ id }: { id: number }) {
return actionData({
foo: 'bar'
})
}
// page.tsx
'use client'
import { useAction } from 'http-react'
import { getData } from '@/actions'
export default function Page() {
// data has static typing inferred from the action result
const { data, isPending, error } = useAction(getData, {
params: {
id: 1 // This will show an error if id is not a number
}
})
return isPending ? (
<p>Loading...</p>
) : error ? (
<p>Something went wrong</p>
) : (
<div>
<h2>Welcome</h2>
<p>{data.foo}</p>
</div>
)
}
It supports many features that are necessary in modern applications, while giving developers full control over the request configuration:
and more!
npm install --save http-react
Or
yarn add http-react
FAQs
React hooks for data fetching
The npm package http-react receives a total of 84 weekly downloads. As such, http-react popularity was classified as not popular.
We found that http-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.