This unofficial Better Auth Nuxt demo should allow you to integrate your preferred database. It uses Tailwind 4, Nuxt 4, latest shadcn-vue, page protection and SQLite for login.
The official Better Auth Nuxt repo does not seem to work correctly for me, and it’s based on older Nuxt, Tailwind and shadcn-vue. I have updated it, added features and fixed security bugs allowing you to use whatever Better Auth database integrations you like.
TL;DR
This demo uses Tailwind 4, Nuxt 4, latest , has page protection, allows you to change your password and does not suffer from client loading problems. You log in using SQLite, the session is automatically saved, and you can change your password and generate a password reset link.
Setup
Nuxt 4
First, generate a new Nuxt 4 repo.
Tailwind
Follow official instructions to install .
⚠️ DO NOT USE Nuxt Tailwind Module directly.
But, install it manually:
Vue ShadCN
Configure ShadCN Vue for Nuxt. You will need to install all components manually that you need.
📝 There is an error with the all flag, as it will try to install old modules. Unfortunately, the only work around is to install the components manually.
Better Auth
Follow the installation guide. Here is a quick version.
Install the package. We will use better-auth/vue.
Generate config.
We will generate library files in a following section.
Install Temp Database
Fastest SQLite in Node.js.
.env
Setup your config.
Nuxt Config
Create the catch all server route.
This will handle all authentication server requests.
lib/auth-client.ts
Let’s import the reusable client functions.
lib/auth.ts
Generate a better auth instance.
📝 You must config an email server later to send emails, for now you can just print the URL.
📝 Our database will the the file db.sqlite. It will NOT persist when deployed, so you must you a different hosted database. This is for testing on
Repo: GitHub
Protect Your Pages
📝 We don’t want login pages to be seen when logged-in, and we don’t want login-protected pages to be seen without a session. Our server auth handles these cookies and paths for us!
Change Password
📝 We import our auth-client functions to perform the client function for us. We MUST use a form to prevent warnings in Chrome, which is good practice anyway.
Dashboard
We want to load the session on the server, NOT on the client with a delay, like the original demo.
📝 useAuth has many functions we can configure to work in any scenario. useAsyncData loads on the sever and hydrates to the client.
Forget Password
📝 We must configure an email server to work in production. This setup is similar to previous pages.
Home
📝 Nothing special here, except for checking for a session.
Reset Password
📝 Same setup as before, import our resetPassword function from our auth library.
Sign In
📝 Manually forward router to /dashboard upon success.
📝 We use alert for errors, but this is easily configurable.
Bonus
We can easily use any database integration we like.
Postgres
Now, go build the rest of your app!
Repo:












