RDSDataAPI adapter is not working - error: [BetterAuthError: Failed to initialize database adapter]
I am trying to hook my better auth against an AWS RDS database using the RDS Data API, which is a supported dialect by Kysely. However, after manually running database migration and verifying database itself is connectable, I run into this error that is not very informative: [BettertAuthError: Failed to initialize database adapter]. I looked at my set-up and felt like I followed the right instructions. Here is my set-up below
import { Kysely } from 'kysely';
import { DataApiDialect } from 'kysely-data-api';
import { RDSData } from '@aws-sdk/client-rds-data';
interface Database {
user: UserTable;
session: SessionTable;
account: AccountTable;
verification: VerificationTable;
}
export const db = new Kysely<Database>({
dialect: new DataApiDialect({
mode: 'postgres',
driver: {
database: process.env.DB_NAME '',
secretArn: process.env.DB_SECRET_ARN '',
resourceArn: process.env.DB_CLUSTER_ARN || '',
client: new RDSData(), // Use default credential
},
}),
});
export const auth = betterAuth({
database: db,
...
});
GitHub
GitHub - sst/kysely-data-api
Contribute to sst/kysely-data-api development by creating an account on GitHub.
1 Reply
@admin appreciate any pointers
Resolved it, this is the change that solved it. I'm not sure if documentation has it: database: {
db: db,
type: 'postgres',
}, but it has to go into a database wrapper instead of direct db