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

@authtara/sdk

v1.0.4

Published

Authentication SDK for Identity Provider as a Service (Authtara) - JavaScript & React SDK

Downloads

18

Readme

@authtara/sdk

JavaScript & React SDK untuk Authentication dengan Identity Provider as a Service (Authtara).

📦 Installation

npm install @authtara/sdk
# or
bun add @authtara/sdk
# or
yarn add @authtara/sdk

🚀 Quick Start

JavaScript SDK

import { AuthClient } from '@authtara/sdk';

// Initialize client
const auth = new AuthClient({
  clientId: 'pk_abc123', // Required: Application client ID
  apiUrl: 'https://api.yourdomain.com/widget/api', // Optional: Default '/widget/api'
});

// Sign up
const result = await auth.signUp({
  email: '[email protected]',
  password: 'SecurePass123!',
  name: 'John Doe',
});

// Sign in
const signInResult = await auth.signIn({
  email: '[email protected]',
  password: 'SecurePass123!',
});

// Get current user
const user = await auth.getUser();

// Sign out
await auth.signOut();

React SDK

import { AuthProvider, useAuth, SignIn, SignUp } from '@authtara/sdk/react';
import { AuthClient } from '@authtara/sdk';

// Initialize client
const authClient = new AuthClient({
  clientId: 'pk_abc123',
  apiUrl: 'https://api.yourdomain.com/widget/api',
});

// Wrap your app
function App() {
  return (
    <AuthProvider client={authClient}>
      <YourApp />
    </AuthProvider>
  );
}

// Use in components
function LoginPage() {
  const { signIn, user, isAuthenticated } = useAuth();

  if (isAuthenticated) {
    return <div>Welcome, {user?.name}!</div>;
  }

  return <SignIn onSuccess={result => console.log('Signed in!', result)} />;
}

📚 API Reference

AuthClient

Methods

  • signUp(data: SignUpData): Promise<AuthResult>
  • signIn(data: SignInData): Promise<AuthResult>
  • signOut(): Promise<void>
  • getUser(): Promise<User | null>
  • refreshSession(): Promise<Session>
  • isAuthenticated(): boolean
  • getCurrentUser(): User | null

Events

  • on(event: 'signIn' | 'signOut' | 'userChanged' | 'error', handler: Function): void
  • off(event: string, handler: Function): void

React Hooks

  • useAuth() - Main auth hook
  • useUser() - Get current user
  • useSignIn() - Sign in with loading state
  • useSignUp() - Sign up with loading state
  • useSignOut() - Sign out with loading state

React Components

  • <AuthProvider> - Context provider
  • <SignIn> - Pre-built sign in form
  • <SignUp> - Pre-built sign up form
  • <UserButton> - User info & sign out button

🛠️ Development

Local Development Setup

SDK ini menggunakan Bun workspaces untuk development yang lebih efisien. Tidak perlu publish ke npm untuk testing perubahan lokal.

Prerequisites

  • Bun >= 1.0.0
  • TypeScript >= 5.0.0

Development Workflow

  1. Build SDK:

    bun run build
  2. Watch mode (auto-rebuild saat perubahan):

    bun run dev:watch
  3. Type checking:

    bun run type-check
  4. Linting:

    bun run lint
    bun run lint:fix  # Auto-fix issues

Menggunakan di Project Lain (Workspace)

Untuk menggunakan SDK ini di project lain dalam workspace yang sama:

  1. Pastikan workspace sudah dikonfigurasi di root package.json:

    {
      "workspaces": ["authtara-sdk", "your-app"]
    }
  2. Di project lain, gunakan workspace dependency:

    {
      "dependencies": {
        "@authtara/sdk": "workspace:*"
      }
    }
  3. Build SDK dan jalankan watch mode:

    # Terminal 1: Watch SDK
    cd authtara-sdk
    bun run dev:watch
    
    # Terminal 2: Run your app
    cd your-app
    bun run dev

Publish ke NPM

Untuk publish ke npm registry:

  1. Pastikan semua perubahan sudah di-build:

    bun run build
  2. Update version di package.json jika perlu:

    # Manual atau menggunakan npm version
    npm version patch|minor|major
  3. Publish:

    npm publish

    Script prepublishOnly akan otomatis menjalankan build sebelum publish.

📖 Documentation

Full documentation available at: [Your Docs URL]

🤝 Contributing

Contributions welcome! Please read our contributing guidelines.

📄 License

MIT

🔗 Links