
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
nuxt-betterauth-cf
Advanced tools
Add Better Auth to you Nuxt project powered by Cloudflare with ease.
Install the module to your Nuxt application with one command:
npx nuxi module add nuxt-betterauth-cf
Install the dependencies in your project.
pnpm add -D drizzle-kit wrangler @cloudflare/workers-types
pnpm add drizzle-kit better-auth
Add this to your package.json file
{
// ...
"scripts": {
// ...
"db:generate": "pnpm drizzle-kit generate",
"db:migrate": "wrangler d1 migrations apply <your app name> --local",
"auth:generate": "pnpx @better-auth/cli generate --output ./db/schemas/auth.ts"
}
}
Create a wrangler.jsonc
or wranger.toml
file in the root of your project:
https://developers.cloudflare.com/workers/wrangler/configuration/
The module automatically creates these files in your project:
.
βββ auth
β βββ config.ts
βββ db
β βββ schemas
β βββ app.ts
β βββ auth.ts
β βββ index.ts
βββ drizzle.config.ts
βββ lib
βββ auth.ts
The module is somewhat opinionated in terms of how Cloudflare D1 and Cloudflare KV is integrated.
To setup modules, hooks etc. for Better Auth, go to the auth/config.ts
file.
From here you can centrally manage your server- and client side configuration.
It's important that the file exports a config
and client
.
import { defineAuthConfig, defineAuthClientConfig } from 'nuxt-betterauth-cf/config'
import { username } from "better-auth/plugins"
import { usernameClient } from "better-auth/client/plugins"
export const config = defineAuthConfig({
plugins: [username()]
})
export const client = defineAuthClientConfig({
plugins: [usernameClient()]
})
This module comes with a useAuth
composable for easy interaction with Better Auth.
Please infer the return type to see the different helpers provided by the composable.
You can always access the raw Better Auth client through .client
.
<script setup lang="ts">
const auth = useAuth()
const client = auth.client // Maps to the raw Better Auth client
</script>
This module automatically adds the api endpoint required by Better Auth.
If you want to setup protected routes you can use the defineAuthenticatedEventHandler
.
It's auto-imported for you and works the same as defineEventHandler
with the difference that it checks for a valid Better Auth session or throws and error.
The current session and Better Auth instance is provided through the event.context
.
export default defineAuthenticatedEventHandler(async (event) => {
const session = event.context.session // The current session
const auth = event.context.auth // The Better Auth instance
})
Inspired by atinux/nuxthub-better-auth
v1.0.17
FAQs
Nuxt, Better Auth and Cloudflare π₯
The npm package nuxt-betterauth-cf receives a total of 348 weekly downloads. As such, nuxt-betterauth-cf popularity was classified as not popular.
We found that nuxt-betterauth-cf demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last weekβs supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.