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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-config-hook

v1.1.0

Published

A React hook for fetching and managing configuration from an API

Readme

react-config-hook

A React hook for managing dynamic backend URLs and configurations in React applications. This package helps you manage your service endpoints dynamically without hardcoding URLs.

📚 Documentation

Before installing, please read the complete documentation at: Dynamic URL Management Documentation

🚀 Installation

npm install react-config-hook
# or
yarn add react-config-hook

⚡ Quick Usage

import { useConfig } from 'react-config-hook';

function App() {
  const { config, error, loading } = useConfig();

  if (loading) return <div>Loading configuration...</div>;
  if (error) return <div>Error: {error}</div>;

  // Access your service URL
  const serviceUrl = config.ms; // Replace 'ms' with your service key

  return <div>Service URL: {serviceUrl}</div>;
}

⚙️ Environment Setup

REACT_APP_APP_NAME=Your_App_Name_From_Admin_Panel
REACT_APP_ENVIRONMENT=Your_Environment_From_Admin_Panel
REACT_APP_CONFIG_API_KEY=Your_API_Key

For Next.js projects, use NEXT_PUBLIC_ prefix instead of REACT_APP_ .

🔑 Getting Your API Key

🌟 Features

  • Dynamic backend URL management
  • Environment-based configuration
  • Automatic error handling
  • Loading state management
  • TypeScript support
  • React and Next.js compatibility

💡 Example Usage with Axios

import { useConfig } from 'react-config-hook';
import axios from 'axios';

function UserService() {
  const { config, error, loading } = useConfig();

  if (loading) return <div>Loading...</div>;
  if (error) return <div>Error: {error}</div>;

  const handleLogin = async (username, password) => {
    try {
      const response = await axios.post(`${config.authService}/login`, {
        username,
        password
      });
      // Handle response
    } catch (err) {
      // Handle error
    }
  };

  return <div>Your component JSX</div>;
}

📝 License

MIT

🤝 Support

⚠️ Important Note

Make sure to check the full documentation for:

- Detailed setup instructions
- Advanced usage examples
- Troubleshooting guide
- Best practices
- API reference

This README now includes:
1. Clear installation instructions
2. Link to the main documentation
3. Quick start guide
4. Environment setup
5. Example usage
6. Support information
7. Important features
8. Proper formatting and emojis for better readability