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 🙏

© 2024 – Pkg Stats / Ryan Hefner

site-auth-react

v1.0.2

Published

Site auth react & next.js package

Downloads

11

Readme

Site Auth - Secure every deployment

Introduction

Site Auth is a unique authentication service designed to act as a secure gateway, ensuring that only specific, authorized users can access your website. It functions as an authentication layer that adds an extra level of security to any website by restricting access to verified users only.

Features

  • Selective Access: Restrict access to your website to only authorized users.
  • Seamless Integration: Easily integrates with your projects with our multi-framework support.
  • Developer-Friendly: Designed for ease of use and quick implementation.
  • Extensible: Easily extendable to meet your unique authentication needs.
  • Dashboard Management: Provides an interface to manage website access, users, analytics, and more.

Installation

To install the SiteAuth package, run the following command:

npm install site-auth-react

Usage

Here's a step-by-step guide to quickly set up SiteAuth in your project. Choose the method that best suits your project and follow the instructions below.

React

Follow these steps to set up SiteAuth in your React app.

Note: TypeScript is also supported.

  1. Create an account on Site Auth.

  2. Get Website ID by adding your website and users to the SiteAuth dashboard.

  3. Install Package:

    npm install site-auth-react
  4. Wrap your app with SiteAuthProvider in App.js:

    import { SiteAuthProvider } from "site-auth-react";
    
    function App() {
      return (
        <SiteAuthProvider>
          <YourAppComponents />
        </SiteAuthProvider>
      );
    }
  5. Use the SiteAuthScreen component for authentication:

    import { SiteAuthScreen } from "site-auth-react";
    
    function AuthPage() {
      return <SiteAuthScreen websiteId="your-website-id" />;
    }

Next.js

Follow these steps to set up Site Auth in your Next.js app.

Note: TypeScript is also supported.

  1. Create an account on Site Auth.

  2. Get Website ID by adding your website and users to the SiteAuth dashboard.

  3. Install Package:

    npm install site-auth-react
  4. Use the SiteAuthScreen component for authentication:

    <SiteAuthScreen websiteId="your-website-id" />
  5. Create a custom wrapper SiteAuthWrapper & use useSiteAuth hook to check authentication status:

    import { SiteAuthScreen, useSiteAuth } from "site-auth-react";
    
    const SiteAuthWrapper = ({ children }) => {
      const { isAuthenticated, loading } = useSiteAuth();
    
      if (loading) {
        // You can show a loading spinner here
        return <div>Loading...</div>;
      }
    
      return (
        <>
          {!isAuthenticated && <SiteAuthScreen websiteId="your-website-id" />}
          {isAuthenticated && children}
        </>
      );
    };
    
    export default SiteAuthWrapper;
  6. Wrap your app with SiteAuthProvider & SiteAuthWrapper in layout.js:

    import { SiteAuthProvider } from "site-auth-react";
    import SiteAuthWrapper from "./SiteAuthWrapper";
    
    export default function RootLayout({ children }) {
      return (
        <html lang="en">
          <body>
            <SiteAuthProvider>
              <SiteAuthWrapper>{children}</SiteAuthWrapper>
            </SiteAuthProvider>
          </body>
        </html>
      );
    }

Custom Hook

Site Auth provides a custom hook to help you manage authentication in your app.

useSiteAuth

A hook that provides authentication status and loading state.

import { useSiteAuth } from "site-auth-react";

function Dashboard() {
  const { isAuthenticated, loading } = useSiteAuth();

  if (loading) {
    return <p>Loading...</p>;
  }

  if (!isAuthenticated) {
    return <p>You need to log in</p>;
  }

  return <p>Welcome to the dashboard!</p>;
}

Dashboard

The SiteAuth dashboard provides a comprehensive interface for managing access control, websites, and users. Here’s an overview of its key features:

Access Control

Manage and restrict access to your website by specifying which users are allowed to authenticate and access the content.

  • Define users and their respective passwords

Manage Websites

Easily manage multiple websites and control their authentication settings.

  • Add new websites
  • Edit website settings
  • Delete websites

Analytics

View analytics on user activity, login attempts, and more.

  • View user activity
  • Track login attempts
  • Date wise analytics

Profile Management

Manage user profile settings from the dashboard.

  • Update profile information
  • Change password

Examples

Here are some examples of how you can use SiteAuth in your projects.

React

React Demo

Next.js

Next.js Demo