Skip to content

refactor(auth)!: split session state from client actions#339

Open
onmax wants to merge 1 commit intomainfrom
fix/pinia-auth-action-facades
Open

refactor(auth)!: split session state from client actions#339
onmax wants to merge 1 commit intomainfrom
fix/pinia-auth-action-facades

Conversation

@onmax
Copy link
Copy Markdown
Collaborator

@onmax onmax commented May 6, 2026

This is a breaking cleanup for the Pinia issue found while testing #295.

useUserSession() now returns only session state and session lifecycle actions, so it can be returned directly from Pinia setup stores without forwarding Better Auth's dynamic client proxies through store state.

Auth calls move to explicit composables (which is much better dx overall!):

const signInEmail = useSignIn('email')
const signUpEmail = useSignUp('email')
const client = useAuthClient()
const sendVerificationEmail = useAuthClientAction(client => client.sendVerificationEmail)

Old patterns like these no longer work:

const { signIn, signUp, client } = useUserSession()
userStore.signIn.email(...)
userStore.authClient.sendVerificationEmail(...)

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 6, 2026

Deployment failed with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/maximogarciamartinezs-projects?upgradeToPro=build-rate-limit

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 6, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@onmax/nuxt-better-auth@339

commit: bef644a

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 6, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
better-auth bef644a May 06 2026, 02:10 PM

@onmax onmax force-pushed the fix/pinia-auth-action-facades branch 2 times, most recently from 202af42 to 2b23ae7 Compare May 6, 2026 13:49
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nuxt-better-auth-docs Ready Ready Preview, Comment May 6, 2026 1:51pm

@onmax onmax changed the title fix(auth): preserve forwarded auth actions in pinia stores refactor(auth): split session state from client actions May 6, 2026
@onmax onmax changed the title refactor(auth): split session state from client actions refactor(auth)!: split session state from client actions May 6, 2026
@onmax onmax force-pushed the fix/pinia-auth-action-facades branch from 2b23ae7 to bef644a Compare May 6, 2026 14:07
@jd-solanki
Copy link
Copy Markdown
Contributor

jd-solanki commented May 6, 2026

This new API seems a bit weird to me:

const signInEmail = useSignIn('email')
const signUpEmail = useSignUp('email')
const client = useAuthClient()
const sendVerificationEmail = useAuthClientAction(client => client.sendVerificationEmail)

Isn't possible to have guessable API like:

auth.signUp.email
auth.signOut

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants