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

@saas-maker/auth-preset

v0.1.0

Published

Foundry auth preset — better-auth with D1 + Google + secure cookie defaults baked in.

Readme

@saas-maker/auth-preset

Foundry-standard wrapper around better-auth. Bakes in Google provider, secure session cookies, and the D1 adapter so every Foundry app gets the same auth posture in two lines.

Install

pnpm add @saas-maker/auth-preset better-auth drizzle-orm

.env.example

BETTER_AUTH_SECRET=<openssl rand -base64 32>
AUTH_URL=https://app.example.com
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
NODE_ENV=production

Server — Cloudflare Workers / OpenNext

// lib/auth.ts
import { createAuth } from '@saas-maker/auth-preset';
import { getCloudflareContext } from '@opennextjs/cloudflare';
import * as schema from './auth-schema';

let _auth: ReturnType<typeof createAuth> | null = null;

export function getAuth() {
  if (_auth) return _auth;
  const { env } = getCloudflareContext();
  _auth = createAuth({ d1: env.DB, schema });
  return _auth;
}

Next.js App Router catch-all route

// app/api/auth/[...all]/route.ts
import { toNextHandler } from '@saas-maker/auth-preset/next';
import { getAuth } from '@/lib/auth';

export const { GET, POST } = toNextHandler(getAuth());

Client — React

// app/providers.tsx
'use client';
import { AuthProvider } from '@saas-maker/auth-preset/client';

export function Providers({ children }) {
  return <AuthProvider>{children}</AuthProvider>;
}
'use client';
import { useSession, useAuthClient } from '@saas-maker/auth-preset/client';

export function Header() {
  const { data: session } = useSession();
  const client = useAuthClient();
  if (!session) return <button onClick={() => client.signIn.social({ provider: 'google' })}>Sign in</button>;
  return <button onClick={() => client.signOut()}>Sign out {session.user.email}</button>;
}

Defaults baked in

| Setting | Default | |---|---| | Provider | google | | Session cookie name | foundry.session | | secure cookie | true in production, false otherwise | | sameSite | lax | | httpOnly | true | | Cross-subdomain cookies | disabled | | trustedOrigins | [baseURL] |

Override anything by passing it explicitly to createAuth({ ... }).

Schema

The D1 adapter expects the standard better-auth tables (user, session, account, verification). Generate them with:

pnpm dlx better-auth-cli generate --schema ./src/lib/auth-schema.ts

Then run a Drizzle migration to create the tables in D1.