Nova
Nova
BABetter Auth
Created by Nova on 2/22/2025 in #help
Accessing Server Plugin Endpoints in getAtoms Callback
Hey everyone! I'm working on a client plugin and need to retrieve the available endpoints from my server plugin within the getAtoms callback. Here's a simplified snippet of my code:
import { BetterAuthClientPlugin } from 'better-auth/types';
import type { bankIDPlugin } from './plugin-server';
import { atom, onMount, task } from 'nanostores';

export const bankIDPluginClient = () => {
return {
id: 'bankid-plugin',
$inferServerPlugin: {} as ReturnType<typeof bankIDPlugin>,
getAtoms: ($fetch) => {
const myAtom = atom({});
onMount(myAtom, () => {
task(() =>
// get the correct endpoint from the plugin
$fetch('auth/bankid/start', { method: 'POST' })
.then(console.log)
);
});
return { myAtom };
}
} satisfies BetterAuthClientPlugin;
};
import { BetterAuthClientPlugin } from 'better-auth/types';
import type { bankIDPlugin } from './plugin-server';
import { atom, onMount, task } from 'nanostores';

export const bankIDPluginClient = () => {
return {
id: 'bankid-plugin',
$inferServerPlugin: {} as ReturnType<typeof bankIDPlugin>,
getAtoms: ($fetch) => {
const myAtom = atom({});
onMount(myAtom, () => {
task(() =>
// get the correct endpoint from the plugin
$fetch('auth/bankid/start', { method: 'POST' })
.then(console.log)
);
});
return { myAtom };
}
} satisfies BetterAuthClientPlugin;
};
Is there a recommended way to get a list of all available server plugin endpoints (or otherwise reference them) within the client plugin’s getAtoms callback? Any tips or best practices would be greatly appreciated!
1 replies