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

@cubicecho/graphql-better-auth

v1.2.0

Published

better-auth's endpoints as a GraphQL schema extension: typed SDL and resolvers, generated from the auth instance.

Readme

@cubicecho/graphql-better-auth

better-auth's endpoints as a GraphQL schema extension. Hand it an auth instance and it gives back typed SDL and resolvers, so clients sign in, read the session and manage accounts through the GraphQL API they already use.

Every auth.api endpoint a client may call becomes a query or a mutation. Arguments, result types and models come from the instance itself, with the fields your config adds, so a new better-auth plugin brings its endpoints along. OAuth callbacks and other redirect targets stay on HTTP.

Install

npm install @cubicecho/graphql-better-auth better-auth graphql

Node 22 or later, ESM only. better-auth 1.7 or later, graphql 16 or 17.

Quick start

Save this as quick-start.mjs and run node quick-start.mjs. Keep baseURL in your own config: without it, better-auth refuses a sign-in from a browser, because a GraphQL request doesn't tell it its address.

import { applyBetterAuthGraphQL, betterAuthGraphQL } from '@cubicecho/graphql-better-auth';
import { betterAuth } from 'better-auth';
import { memoryAdapter } from 'better-auth/adapters/memory';
import { bearer } from 'better-auth/plugins';
import { buildSchema, graphql } from 'graphql';

const auth = betterAuth({
  baseURL: 'http://localhost:3000',
  secret: 'replace-this-with-a-long-random-secret',
  database: memoryAdapter({ user: [], session: [], account: [], verification: [] }),
  emailAndPassword: { enabled: true },
  plugins: [bearer()],
});

const built = betterAuthGraphQL(auth, {
  // Where better-auth finds the session: a cookie or a bearer token.
  headers: (context) => context.headers,
  include: ['signUpEmail', 'signInEmail', 'getSession', 'signOut'],
});

// Your own schema, with the auth fields added.
const schema = applyBetterAuthGraphQL(buildSchema('type Query { ping: Boolean }'), built);

const signUp = await graphql({
  schema,
  source: `mutation {
    signUpEmail(name: "Ada", email: "[email protected]", password: "correct horse battery") { token }
  }`,
  contextValue: { headers: new Headers() },
});

const session = await graphql({
  schema,
  source: '{ getSession { user { name email } session { expiresAt } } }',
  contextValue: { headers: new Headers({ authorization: `Bearer ${signUp.data.signUpEmail.token}` }) },
});
console.log(JSON.stringify(session.data, null, 2));

Before you go live, read Security: better-auth's rate limits and router-wide CSRF check don't run on GraphQL calls, so they are yours to add.

Documentation

License

MIT