npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vigilio/react-native-fetching

v0.0.1

Published

A data fetching library for React Native Expo with caching, retry, and background refetch support

Readme

@Vigilio/Preact-fetching (React Native Expo)

A data fetching hooks library for React Native Expo with caching, retry, and background refetch support.

Installation

npx expo install react
# Optional: for refetchOnReconnect support
npx expo install @react-native-community/netinfo

Getting Started

useQuery: consume data fetching (GET)

import { useQuery } from "@vigilio/preact-fetching";
import { View, Text, ActivityIndicator } from "react-native";

async function getUsers(url: string, signal: AbortSignal) {
  const response = await fetch("http://yourhost/api" + url, { signal });
  const result = await response.json();
  return result;
}

export function UsersScreen() {
  const { isLoading, data, isSuccess, isError, refetch } = useQuery(
    "/users",
    getUsers,
  );

  if (isLoading) return <ActivityIndicator />;
  if (isError) return <Text>Error loading users</Text>;
  if (isSuccess) return <Text>{JSON.stringify(data)}</Text>;

  return <View />;
}

useQuery Options

const options = {
  skipFetching: false, // skip fetch -> default false
  placeholderData: null, // placeholder -> default null
  transformData: null, // transform success data -> default null
  staleTime: null, // refetch interval in seconds (1 = 1000ms)
  refetchIntervalInBackground: false, // refetch when app returns to foreground (uses AppState)
  onError: null, // callback on error (err) => {}
  onSuccess: null, // callback on success (data) => {}
  refetchOnReconnect: false, // refetch on network reconnect (requires @react-native-community/netinfo)
  delay: null, // delay before fetch in seconds
  retry: 3, // number of retries on error
  retryDelay: null, // delay between retries in seconds
  clean: true, // clean cache on refetch
  isCaching: null, // enable in-memory caching (true or number for TTL ms)
  isMemory: null, // enable memory storage (true or number for TTL ms)
};

const showUser = useQuery("/users", getUsers, options);

useMutation: consume data fetching (POST/PUT/DELETE/PATCH)

import { useMutation } from "@vigilio/preact-fetching";
import { View, Text, TextInput, Pressable } from "react-native";
import { useState } from "react";

interface Body {
  name: string;
}

async function addUser(url: string, body: Body, signal: AbortSignal) {
  const response = await fetch("http://yourhost/api" + url, {
    method: "POST",
    body: JSON.stringify(body),
    headers: { "Content-Type": "application/json" },
    signal,
  });
  return response.json();
}

export function AddUserScreen() {
  const { mutate, isLoading } = useMutation("/users", addUser);
  const [name, setName] = useState("");

  function handleSubmit() {
    mutate(
      { name },
      {
        onSuccess: (data) => console.log(data),
        onError: (error) => console.log(error),
      },
    );
  }

  return (
    <View>
      <TextInput value={name} onChangeText={setName} placeholder="Name" />
      <Pressable onPress={handleSubmit}>
        <Text>{isLoading ? "Loading..." : "Send"}</Text>
      </Pressable>
    </View>
  );
}

mutateAsync

const { mutateAsync } = useMutation("/users", addUser);

async function handleSubmit() {
  try {
    const data = await mutateAsync({ name });
    console.log(data);
  } catch (err) {
    console.error(err);
  }
}

Mutate Options

{
    onSuccess?: (data) => {};
    onError?: (error) => {};
    transformData?: (data) => Data; // modify response data
}

Using with Axios

import axios from "axios";
import { useQuery } from "@vigilio/preact-fetching";

const api = axios.create({ baseURL: "http://yourhost/api" });

interface User {
  id: number;
  name: string;
}

async function showUsers(url: string) {
  const { data } = await api.get<User[]>(url);
  return data;
}

const { isLoading, data } = useQuery("/users", showUsers);

Dynamic Params (React Navigation)

import { useQuery } from "@vigilio/preact-fetching";
import { useRoute } from "@react-navigation/native";
import { View, Text, ActivityIndicator } from "react-native";

async function showById(url: string) {
  const response = await fetch("http://yourhost/api" + url);
  return response.json();
}

export function UserDetailScreen() {
  const route = useRoute();
  const { id } = route.params as { id: string };

  const { isLoading, data, isSuccess, isError, error } = useQuery(
    `/users/${id}`,
    showById,
  );

  if (isLoading) return <ActivityIndicator />;
  if (isSuccess) return <Text>{JSON.stringify(data)}</Text>;
  if (isError) return <Text>{JSON.stringify(error)}</Text>;

  return <View />;
}

Platform Notes

  • Cache/Memory: Both cache and memory are in-memory only (no persistent storage). For persistent caching, integrate @react-native-async-storage/async-storage separately.
  • refetchIntervalInBackground: Uses React Native AppState to detect when the app returns to the foreground.
  • refetchOnReconnect: Requires @react-native-community/netinfo as an optional dependency.