NextAuth custom adapter creation for an API endpoints

18 views Asked by At

I have a Rest Api application with back-end written in Spring Boot and UI in NextJS. This is my first experience wit Nextjs. NextAuth docs says that to do a connection between my UI and API we can create a custom adapter. I'm struggling to make that work using nextauth with TypeScript.

Here is the adapter I'm working on:

export const adapter: Adapter = async (options) => {
    // Base URL of your Spring Boot API
    const baseURL = api.base_uri;

    return {
        async getAdapter({ session, ...appOptions }) {
            return {
                async createUser(profile: any) {
                    await createUser(profile)
                },
                async updateUser(user: any) {
                    await updateUser(user)
                }
            };
        },
    };
};

The types are not the same. My createUser() takes a user: z.infer<typeof RegisterSchema> and return a promise using Axios Adapter interface createUser() takes an AdapterUser and return Awaitable<AdapterUser> I don't know if I'm doing write.

0

There are 0 answers