Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

http-react

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-react

React hooks for data fetching

  • 3.3.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
91
increased by30%
Maintainers
1
Weekly downloads
 
Created
Source

HTTP React

Http React is a React hooks library for data fetching. It's built on top of the native Fetch API.

Overview

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
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 supports many features that are necessary in modern applications, while giving developers full control over the request configuration:

  • Server-Side Rendering
  • Server actions
  • React Native
  • Request deduplication
  • Suspense
  • Refresh
  • Retry on error
  • Pagination
  • Local mutation (Optimistic UI)
  • qraphql

and more!

Installation:
npm install --save http-react

Or

yarn add http-react

For production apps

<!-- Add React and ReactDOM -->
<script
  src="https://unpkg.com/react@18.2.0/umd/react.production.min.js"
  crossorigin
></script>

<script
  src="https://unpkg.com/react-dom@18.2.0/umd/react-dom.production.min.js"
  crossorigin
></script>

<!-- Add Http React -->
<script src="https://unpkg.com/http-react/dist/browser/http-react.min.js"></script>

Getting started

Keywords

FAQs

Package last updated on 01 May 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc