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

@danielvm/neon-astro-auth

v1.0.1

Published

Neon Database Auth adapter for Astro

Downloads

198

Readme

Neon Auth Astro Adapter

npm version License npm downloads

Astro adapter for Neon Auth — a Better Auth integration. Provides an adapter, API handler, middleware, client, and Astro integration in a single package.

Features

  • Adapter — Maps Astro's APIContext to Neon Auth's RequestContext interface
  • API Handler — Proxy auth requests to your Better Auth server
  • Middleware — Protect routes with role-based auth decisions
  • Client — Pre-configured createAuthClient() for browser usage
  • Integration — One-liner neonAuth() auto-wires routes and middleware in astro.config.mjs
  • ESM-only — Modern output, tree-shakeable

Installation

npm install @danielvm/neon-astro-auth
# or
pnpm add @danielvm/neon-astro-auth
# or
yarn add @danielvm/neon-astro-auth

Peer dependency: Astro >=5.0.0 (optional — only needed if you use the integration or middleware).

Quick Start

Option 1: Integration (recommended)

Add the integration to your astro.config.mjs:

import { defineConfig } from 'astro/config';
import neonAuth from '@danielvm/neon-astro-auth/integration';

export default defineConfig({
  integrations: [
    neonAuth({
      baseUrl: 'https://your-better-auth-server.com',
      cookies: {
        secret: process.env.AUTH_SECRET!,
      },
    }),
  ],
});

This automatically injects the API route and middleware.

Option 2: Manual wiring

API routesrc/pages/api/auth/[...slug].ts:

import type { APIRoute } from 'astro';
import { createAstroAuth } from '@danielvm/neon-astro-auth/server';

const auth = createAstroAuth({
  baseUrl: 'https://your-better-auth-server.com',
  cookies: { secret: process.env.AUTH_SECRET! },
});

export const ALL: APIRoute = auth.handler;

Middlewaresrc/middleware.ts:

import { defineMiddleware } from 'astro/middleware';
import { createAstroAuth } from '@danielvm/neon-astro-auth/server';

const auth = createAstroAuth({
  baseUrl: 'https://your-better-auth-server.com',
  cookies: { secret: process.env.AUTH_SECRET! },
});

export const onRequest = defineMiddleware(auth.middleware);

Clientsrc/lib/auth.ts:

import { createAuthClient } from '@danielvm/neon-astro-auth';

export const authClient = createAuthClient();

Configuration

| Option | Type | Default | Description | |--------|------|---------|-------------| | baseUrl | string | — | URL of your Better Auth server | | cookies.secret | string | — | Auth cookie secret (min 32 chars) | | cookies.sessionDataTtl | number | 600 | Session data TTL in seconds | | cookies.domain | string | — | Cookie domain override | | cookies.sameSite | string | 'lax' | SameSite policy ('lax' | 'strict' | 'none') |

API

@danielvm/neon-astro-auth

import { createAuthClient } from '@danielvm/neon-astro-auth';

Creates a pre-configured Better Auth client for browser usage.

@danielvm/neon-astro-auth/server

import { createAstroAuth } from '@danielvm/neon-astro-auth/server';

const auth = createAstroAuth(config);
//    ^?.handler     — Astro API route handler
//    ^?.middleware  — Astro middleware function
//    ^?.auth        — Better Auth server instance

Development

# Install
pnpm install

# Build
npx tsdown

# Test
npx vitest run

# Typecheck
npx tsc --noEmit

# Watch mode
npx tsdown --watch

Note: Use npx commands directly. Do not use pnpm run for build/test (see pnpm v11.1.2 issue).

Contributing

  1. Read specs/ and CONVENTIONS.md
  2. Every change follows TDD: RED (failing test) → GREEN (impl) → REFACTOR
  3. Run tests after every change: npx vitest run
  4. Commits must follow Conventional Commits (Angular)
  5. Open a PR against main

License

Apache-2.0 — see LICENSE