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

based-modal

v1.0.0

Published

> **Note:** > This package is for server-side (API, server actions, backend) use only. > There are no frontend (React) components or hooks exported. > Do not import this package in client-side code.

Readme

Note: This package is for server-side (API, server actions, backend) use only. There are no frontend (React) components or hooks exported. Do not import this package in client-side code.

based-modal (actions)

A Next.js/Node.js authentication and wallet API kit for Ethereum and Solana, with utilities for serialization and contract interaction, designed for serverless and API route usage.


Features

  • NextAuth-based multi-provider authentication (Google, GitHub, Twitter, EVM/Solana wallet)
  • Social and wallet login support
  • Secure server-side contract interaction endpoints (EVM/Solana)
  • Serialization/deserialization helpers for cross-network data
  • User profile management and keypair generation
  • All API endpoints and helpers are SSR/serverless-friendly

Installation

yarn add based-modal

Peer dependencies:

  • next-auth
  • ethers
  • @solana/web3.js
  • @coral-xyz/anchor
  • tweetnacl
  • bip39
  • shortid
  • based-shared (if using shared types)

Usage

1. API Route Handlers

You can use the provided handlers in your Next.js API routes or server actions.

// pages/api/auth/[...nextauth].ts
import { handlers } from "based-modal/actions";
export default handlers;

Or for app directory:

// app/api/auth/[...nextauth]/route.ts
import { handlers } from "based-modal/actions";
export const { GET, POST } = handlers;

2. Auth Helpers

You can use the exported helpers for authentication and session management:

import { auth, signIn, signOut } from "based-modal/actions";

// Usage in server actions or API routes
const session = await auth();
await signIn(/* ... */);
await signOut(/* ... */);

3. Web3 Handler

For server-side contract interaction (social wallet, EVM, Solana):

import { basedAuthHandler } from "based-modal/actions";

// In your API route:
export const POST = basedAuthHandler;
  • Supports operations: "transfer", "write-contract" (see source for details)
  • Only available to authenticated users with a social profile

4. Serialization Utilities

For encoding/decoding cross-network data:

import { serialize, deserialize } from "based-modal/actions";

const encoded = serialize({ value: 123n });
const decoded = deserialize(encoded, "eth"); // or "sol"

Environment Variables

Set the following in your .env:

AUTH_GOOGLE_ID=...
AUTH_GOOGLE_SECRET=...
AUTH_GITHUB_ID=...
AUTH_GITHUB_SECRET=...
AUTH_TWITTER_ID=...
AUTH_TWITTER_SECRET=...
AUTH_SECRET=...
PREFIX_HASH=your_secret_for_keypair_generation

API

Exports

  • handlers – NextAuth API route handlers (for Next.js API/app routes)
  • auth – Helper to get the current session (async)
  • signIn – Helper to sign in a user (async)
  • signOut – Helper to sign out a user (async)
  • basedAuthHandler – POST handler for server-side web3 operations (transfer, write-contract)
  • serialize – Serialize cross-network data (bigint, BN, SolanaPublicKey)
  • deserialize – Deserialize cross-network data

Advanced/Utility (internal, but useful for extension)

  • saveSocialUser, saveWalletUser, updateOrCreateUserProfile (user profile management)
  • createKeypairs (deterministic keypair generation for EVM/Solana/Sui)

Example: Next.js API Route

// app/api/auth/[...nextauth]/route.ts
import { handlers } from "based-modal/actions";
export const { GET, POST } = handlers;

Example: Server-side Web3

// app/api/web3/route.ts
import { basedAuthHandler } from "based-modal/actions";
export const POST = basedAuthHandler;

Notes

  • This package is server-only: do not use in client/browser code.
  • All web3 operations are protected and require authentication.
  • Serialization utilities are provided for safe cross-network data handling.
  • User profile and keypair helpers are available for advanced use.

For more details, see the source code in src/actions/utils/.