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

devil-frontend

v1.0.4

Published

React hooks and helpers for frontend development

Downloads

442

Readme

devil-frontend

github npm

A collection of React hooks and utility functions for frontend development.

Installation

\\ash npm install devil-frontend \\

Setup

Option 1 � Global Config (Simple React Apps)

\\js // main.jsx or index.js � only once import { configureApi } from 'devil-frontend';

configureApi({ baseURL: import.meta.env.VITE_API_URL }); \\

Option 2 � ApiProvider (Large React Apps)

\\jsx // main.jsx import { ApiProvider } from 'devil-frontend';


Hooks

useApi

Make API calls without setting baseURL every time.

\\jsx import { useApi } from 'devil-frontend';

const { get, post, patch, put, del, setAuthToken, clearToken } = useApi();

// GET const data = await get('/users');

// POST const res = await post('/login', { email, password });

// Set token after login setAuthToken(res.token);

// Clear token on logout clearToken(); \\


useFetch

Fetch data with loading and error states.

\\jsx import { useFetch } from 'devil-frontend';

const { data, loading, error } = useFetch('/api/users');

if (loading) return Loading...; if (error) return Error!; \\


useDebounce

Delay a value update (useful for search inputs).

\\jsx import { useDebounce } from 'devil-frontend';

const [search, setSearch] = useState(''); const debouncedSearch = useDebounce(search, 500);

useEffect(() => { // API call only after 500ms of no typing fetchResults(debouncedSearch); }, [debouncedSearch]); \\


useToggle

Toggle boolean state easily.

\\jsx import { useToggle } from 'devil-frontend';

const [isOpen, toggle] = useToggle(false);

Open/Close \\


useClickOutside

Detect click outside an element (useful for dropdowns/modals).

\\jsx import { useClickOutside } from 'devil-frontend';

const ref = useClickOutside(() => setIsOpen(false));


useInfiniteScroll

Load more data on scroll.

\\jsx import { useInfiniteScroll } from 'devil-frontend';

const { data, loading, hasMore } = useInfiniteScroll('/api/posts'); \\


useOptimistic

Update UI instantly before API response.

\\jsx import { useOptimistic } from 'devil-frontend';

const [optimisticLikes, addOptimisticLike] = useOptimistic(likes);

const handleLike = () => { addOptimisticLike(optimisticLikes + 1); await post('/like', { postId }); }; \\


Utils

\\js import { capitalize, capitalizeWords, formatDate, timeAgo, slugify, isEmptyObject } from 'devil-frontend';

capitalize('hello'); // Hello capitalizeWords('hello world') // Hello World formatDate('2024-01-01'); // Jan 1, 2024 timeAgo('2024-01-01'); // 1 year ago slugify('Hello World'); // hello-world isEmptyObject({}); // true \\


Auth Flow

\\jsx // main.jsx � set baseURL once configureApi({ baseURL: import.meta.env.VITE_API_URL });

// Login page � set token once const { post, setAuthToken } = useApi(); const res = await post('/login', { email, password }); setAuthToken(res.token);

// Any other page � just use it! const { get } = useApi(); get('/dashboard'); // token auto lagega ?

// Logout const { clearToken } = useApi(); clearToken(); \\


License

ISC � sachin-tiwari