Can’t find client plugins

Hello. I just can’t find any client-side plugins. I just tried do import OTP plugin but i didnt find it. Can someone help me? please. I reinstalled all the node modules and the better auth
No description
No description
No description
13 Replies
Dyl
Dyl4w ago
You should import plugins from "better-auth/plugins"
vitozap
vitozapOP4w ago
Ill try again, thank you
vitozap
vitozapOP4w ago
I only have the backend plugin
No description
LightTab2
LightTab24w ago
Client plugins are under better-auth/client/plugins: Sharing my config:
// Core/inherited
import { createAuthClient } from 'better-auth/react'
import { adminClient, anonymousClient,
customSessionClient, jwtClient, usernameClient } from 'better-auth/client/plugins'

// Our source
import type { auth } from '~/auth.ts';

export const authClient = createAuthClient(
{
plugins:
[
adminClient(), anonymousClient(), customSessionClient<typeof auth>(), jwtClient(), usernameClient()
]
}
);
// Core/inherited
import { createAuthClient } from 'better-auth/react'
import { adminClient, anonymousClient,
customSessionClient, jwtClient, usernameClient } from 'better-auth/client/plugins'

// Our source
import type { auth } from '~/auth.ts';

export const authClient = createAuthClient(
{
plugins:
[
adminClient(), anonymousClient(), customSessionClient<typeof auth>(), jwtClient(), usernameClient()
]
}
);
vitozap
vitozapOP4w ago
Thanks man, it was a vs code bug!
vitozap
vitozapOP4w ago
@Dyl
const { data, error } = await authClient.emailOtp.sendVerificationOtp({
email: formData.email,
type: "forget-password",
});
console.log(error, data?.success);
if (error) {
throw error;
}
const { data, error } = await authClient.emailOtp.sendVerificationOtp({
email: formData.email,
type: "forget-password",
});
console.log(error, data?.success);
if (error) {
throw error;
}
Do you know why this method is not throwing an error when it doenst find any user? Because I tried to send an "forgot-password" OTP to an user that doesn't exists in the database and it returns me
success: true
success: true
No description
vitozap
vitozapOP4w ago
and the error object is null
vitozap
vitozapOP4w ago
No description
LightTab2
LightTab24w ago
Because it creates the user, you need to set disableSignUp to true https://www.better-auth.com/docs/plugins/email-otp#sign-in-with-otp
Email OTP | Better Auth
Email OTP plugin for Better Auth.
LightTab2
LightTab24w ago
It's shown in the notes. Also, you can ask @Better Auth to answer basic questions like this, it's better to do that before you bug other people 🙂
Better Auth
Better Auth4w ago
Hi there! It sounds like the answer you need is already noted in our documentation. For basic questions like this, you can also reach out to @Better Auth for a quick answer [1]. If you need any more details or have further inquiries about Better Auth’s features, feel free to ask! Sources: [1] Stripe | Better Auth
Stripe | Better Auth
Stripe plugin for Better Auth to manage subscriptions and payments.
LightTab2
LightTab24w ago
I believe #development is kind of spam channel dedicated for this Wait nvm, this is wrong? And yes, docs are unclear here
sendVerificationOTP: createAuthEndpoint(
"/email-otp/send-verification-otp",
{
...
},
async (ctx) => {
...
if (opts.disableSignUp) {
const user = await ctx.context.internalAdapter.findUserByEmail(email);
if (!user) {
throw new APIError("BAD_REQUEST", {
message: ERROR_CODES.USER_NOT_FOUND,
});
}
} else if (ctx.body.type === "forget-password") {
const user = await ctx.context.internalAdapter.findUserByEmail(email);
if (!user) {
return ctx.json({
success: true,
});
}
}
await options.sendVerificationOTP(
{
email,
otp,
type: ctx.body.type,
},
ctx.request,
);
});
sendVerificationOTP: createAuthEndpoint(
"/email-otp/send-verification-otp",
{
...
},
async (ctx) => {
...
if (opts.disableSignUp) {
const user = await ctx.context.internalAdapter.findUserByEmail(email);
if (!user) {
throw new APIError("BAD_REQUEST", {
message: ERROR_CODES.USER_NOT_FOUND,
});
}
} else if (ctx.body.type === "forget-password") {
const user = await ctx.context.internalAdapter.findUserByEmail(email);
if (!user) {
return ctx.json({
success: true,
});
}
}
await options.sendVerificationOTP(
{
email,
otp,
type: ctx.body.type,
},
ctx.request,
);
});
Found the relevant code and it's... expected behaviour? The user is not created, my bad. Got mislead by the opts.disableSignUp, sorry Anyways it seems if you enable this option you will see the error message Maybe there is some reason for this, maybe this is a bug from an oversight, idk Returning an error here would leak information about whether this user exists to the calling client, but then why is it allowed when opts.disableSignUp is true?
vitozap
vitozapOP4w ago
Gonna try it Thanks a lot!!

Did you find this page helpful?