orpc-better-auth-integration
Use Better Auth inside your oRPC projects without any extra overhead.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use Better Auth inside your oRPC projects without any extra overhead.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Quick reference for Better Notify configuration, patterns, and common gotchas
Interactive setup wizard for adding Better Notify to a TypeScript/JavaScript project
Context and API guidance for Better Notify — end-to-end typed notification infrastructure for Node.js
Seamlessly use AI SDK inside your oRPC projects without any extra overhead.
Use oRPC inside an Astro project.
Functions to encode and decode base64url strings (URL-safe variant of base64).
| name | oRPC Better Auth Integration |
| description | Use Better Auth inside your oRPC projects without any extra overhead. |
| license | MIT |
| metadata | {"author":"Ali Torki","homepage":"https://github.com/ali-master","version":"1.0.0"} |
Better Auth is a framework-agnostic, universal authentication and authorization framework for TypeScript.
Access request headers in your context — manually or via the Request Headers Plugin.
import { os } from '@orpc/server'
export const base = os.$context<{ headers: Headers }>()
Use the plugin's setup.
import { auth } from './auth' // Your Better Auth instance
import { base } from './context'
import { ORPCError } from '@orpc/server'
export const authMiddleware = base.middleware(async ({ context, next }) => {
const sessionData = await auth.api.getSession({
headers: context.headers,
})
if (!sessionData?.session || !sessionData?.user) {
throw new ORPCError('UNAUTHORIZED')
}
return next({
context: {
session: sessionData.session,
user: sessionData.user
},
})
})
Create an authorized base that includes the auth middleware:
import { base } from './context'
import { authMiddleware } from './middlewares/auth'
export const authorized = base.use(authMiddleware)
Now use it to create authenticated procedures:
import { authorized } from './authorized'
export const getMessages = authorized.handler(({ context }) => {
// context.session and context.user are guaranteed to be defined
})