Introducing Reactuals: A React Hook Library for Developers
Hello Dev.to community,
I’m sharing Reactuals, an open-source library of React hooks that simplifies working with browser APIs and UI tasks. You can find it at reactuals.vercel.app. It’s useful for developers in India—whether in Bangalore, Delhi, or elsewhere—who want to build web apps faster.
This post covers what Reactuals does, shows two hooks with code, and explains how to get started or contribute.
What Is Reactuals?
Reactuals provides React hooks to handle browser features and common UI needs without extra complexity. Here’s why it’s helpful:
- Small Size: Use only the hooks you need.
- TypeScript Support: Works well with TypeScript.
- Modern APIs: Includes Web Share, Bluetooth, and more.
-
Responsive Design: Hooks like
useBreakpoint
make layouts easier. - Detailed Docs: See reactuals.vercel.app for examples.
It’s practical for projects of any size, from personal apps to startup products.
Two Hooks to Try
Here are two Reactuals hooks with examples to show how they work.
useBreakpoint
for Screen Sizes
useBreakpoint
helps adjust your app based on screen size using custom breakpoints. It’s simpler than CSS media queries.
import { useBreakpoint } from "reactuals";
const breakpoints = {
sm: 640,
md: 768,
lg: 1024,
};
function ScreenSizeComponent() {
const { breakpoint, isAbove } = useBreakpoint(breakpoints);
return (
<div className="p-4">
<h2>Screen: {breakpoint || "default"}</h2>
<p>{isAbove("md") ? "Large screen" : "Small screen"}</p>
</div>
);
}
Resize your browser to see the change. It’s good for responsive websites or dashboards.
useWebShare
for Sharing Content
useWebShare
lets users share content to apps like WhatsApp or email using the browser’s sharing feature.
import { useWebShare } from "reactuals";
function ShareButton() {
const { share, isSupported } = useWebShare();
const handleShare = async () => {
await share({
title: "Reactuals",
text: "Useful React library!",
url: "https://reactuals.dev",
});
};
return (
<div className="p-4">
<button
onClick={handleShare}
disabled={!isSupported}
className="px-4 py-2 bg-blue-500 text-white rounded disabled:bg-gray-400"
>
Share
</button>
</div>
);
}
Click the button on a phone to see sharing options. It’s useful for blogs or e-commerce sites.
Other Hooks in Reactuals
Reactuals has more hooks, including:
-
useAutofillMonitor
: Detects form autofill. -
useClipboardRead
: Reads clipboard text. -
useWebBluetooth
: Connects to Bluetooth devices. -
useScrollLock
: Locks page scrolling for modals.
Find all hooks at reactuals.vercel.app with examples.
How to Start
To use Reactuals:
- Install:
npm install reactuals
- Import a Hook:
import { useBreakpoint } from "reactuals";
- Use It: Add features like responsive design or sharing to your app.
The docs at reactuals.vercel.app have full details.
Contribute to Reactuals
Reactuals is open-source. You can help by:
- Trying It: Visit reactuals.vercel.app.
- Starring: Star the GitHub repo (replace with your repo link).
- Contributing: Fix bugs or add hooks. Look for “good first issues.”
- Sharing Feedback: Comment below or on GitHub with ideas.
If you build something with Reactuals, I’d like to hear about it.
Why I Created Reactuals
I built Reactuals to avoid rewriting code for browser APIs and UI tasks. It’s meant to help devs, especially in India, build better apps faster. Let’s improve the web together.
Get Started Today
Reactuals helps you create better React apps with less effort. Visit reactuals.vercel.app to explore the hooks. Share your thoughts or ideas in the comments.
Happy coding!
Top comments (0)