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

user-component-react

v1.3.0

Published

React component for user information management

Downloads

340

Readme

User Component React

A React component for managing user information, built with Material-UI and TypeScript.

Installation

npm install user-component-react

Usage

import { UserService } from 'user-component-react';

function App() {
  const handleError = (error: Error) => {
    console.error('Error:', error);
  };

  const handleSuccess = (message: string) => {
    console.log('Success:', message);
  };

  // Pass your JWT when the API requires authentication (optional; omit for unauthenticated requests)
  const bearerToken = 'your-jwt-token-here';

  return (
    <UserService
      apiUrl="https://your-api-url.com"
      userId="me"
      bearerToken={bearerToken}
      onError={handleError}
      onSuccess={handleSuccess}
    />
  );
}

Styles

Styles are included. The component uses Material-UI (CSS-in-JS); wrap your app in MUI's ThemeProvider (and optionally CssBaseline) so the component is styled by default.

To override the default card layout, pass className or sx (MUI's style prop):

<UserService
  apiUrl="..."
  userId="user123"
  className="my-profile-card"
  sx={{ maxWidth: 500, mt: 2 }}
  onError={handleError}
  onSuccess={handleSuccess}
/>

Props

| Prop | Type | Required | Description | |------|------|----------|-------------| | apiUrl | string | Yes | The base URL of your user service API | | userId | string | Yes | The ID of the user to display/edit (use "me" for current user) | | bearerToken | string | null | No | JWT for API authentication; when omitted, requests are sent without Authorization (may get 401) | | onError | (error: Error) => void | No | Callback function for error handling | | onSuccess | (message: string) => void | No | Callback function for success messages | | className | string | No | Class name for the root card | | sx | object | No | MUI sx prop for the root card (merged with defaults) |

Features

  • View user information
  • Edit user profile
  • JWT authentication support
  • Responsive design
  • Material-UI components
  • TypeScript support
  • Error handling
  • Success notifications

API Endpoints

The component uses the following API endpoints:

  • GET /v0/user/{userId} - Fetch user information
  • PUT /v0/user/{userId} - Update user information
  • DELETE /v0/user/{userId} - Delete user account

When bearerToken is provided, all requests include the Bearer token in the Authorization header.

Development

# Install dependencies
npm install

# Build the package
npm run build

Local Testing

To test this component locally with the backend:

  1. Quick Start: See QUICK_START.md for the fastest way to get started
  2. Detailed Guide: See TESTING.md for comprehensive testing instructions

Quick Test

# 1. Start backend services
cd ../..  # Go to project root
docker-compose -f docker-compose.dev.yml up user-service auth-service

# 2. Get a JWT token from auth-service (use Swagger UI at http://localhost:8100/swagger-ui/index.html)

# 3. Start the example app
cd user-component-react/example
npm install
npm start

The example app will open at http://localhost:3000

License

MIT