K
Kinde•3mo ago
chopfitzroy

`onRedirectCallback` receiving `undefined` value in Remix

I am working from the Kinde Remix SDK documentation: https://docs.kinde.com/developer-tools/sdks/backend/remix-sdk/ I have the following code:
// app/routes/kinde-auth.$index.tsx
import { api } from "convex/_generated/api";
import { client } from "~/lib/convex.server";
import { handleAuth } from "@kinde-oss/kinde-remix-sdk";
import { LoaderFunctionArgs } from "@remix-run/node";

export async function loader({ params, request }: LoaderFunctionArgs) {
return await handleAuth(request, params.index, {
onRedirectCallback: ({ user }) => {
console.log('🔥', user);
return client.mutation(api.users.addUser, {
userId: user.id,
})
},
});
}
// app/routes/kinde-auth.$index.tsx
import { api } from "convex/_generated/api";
import { client } from "~/lib/convex.server";
import { handleAuth } from "@kinde-oss/kinde-remix-sdk";
import { LoaderFunctionArgs } from "@remix-run/node";

export async function loader({ params, request }: LoaderFunctionArgs) {
return await handleAuth(request, params.index, {
onRedirectCallback: ({ user }) => {
console.log('🔥', user);
return client.mutation(api.users.addUser, {
userId: user.id,
})
},
});
}
The user is redirected to Kinde just fine but the onRedirectCallback fails with the following error:
🔥 undefined
TypeError: Cannot read properties of undefined (reading 'id')
at Object.onRedirectCallback (/Users/otis/Developer/vtt.tools/app/routes/kinde-auth.$index.tsx:11:20)
at file:///Users/otis/Developer/vtt.tools/node_modules/@kinde-oss/kinde-remix-sdk/dist/index.js:1:3438
at async loader (/Users/otis/Developer/vtt.tools/app/routes/kinde-auth.$index.tsx:7:10)
at async Object.callRouteLoader (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/server-runtime/dist/data.js:66:16)
at async /Users/otis/Developer/vtt.tools/node_modules/@remix-run/router/dist/router.cjs.js:4230:21
at async callLoaderOrAction (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/router/dist/router.cjs.js:4295:16)
at async Promise.all (index 1)
at async callDataStrategyImpl (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/router/dist/router.cjs.js:4170:17)
at async callDataStrategy (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/router/dist/router.cjs.js:3703:19)
at async loadRouteData (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/router/dist/router.cjs.js:3678:19)
at async queryImpl (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/router/dist/router.cjs.js:3523:20)
at async Object.queryRoute (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/router/dist/router.cjs.js:3489:18)
at async handleResourceRequest (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/server-runtime/dist/server.js:361:20)
at async requestHandler (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/server-runtime/dist/server.js:138:18)
at async nodeHandler (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/dev/dist/vite/plugin.js:841:27)
at async /Users/otis/Developer/vtt.tools/node_modules/@remix-run/dev/dist/vite/plugin.js:844:15
🔥 undefined
TypeError: Cannot read properties of undefined (reading 'id')
at Object.onRedirectCallback (/Users/otis/Developer/vtt.tools/app/routes/kinde-auth.$index.tsx:11:20)
at file:///Users/otis/Developer/vtt.tools/node_modules/@kinde-oss/kinde-remix-sdk/dist/index.js:1:3438
at async loader (/Users/otis/Developer/vtt.tools/app/routes/kinde-auth.$index.tsx:7:10)
at async Object.callRouteLoader (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/server-runtime/dist/data.js:66:16)
at async /Users/otis/Developer/vtt.tools/node_modules/@remix-run/router/dist/router.cjs.js:4230:21
at async callLoaderOrAction (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/router/dist/router.cjs.js:4295:16)
at async Promise.all (index 1)
at async callDataStrategyImpl (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/router/dist/router.cjs.js:4170:17)
at async callDataStrategy (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/router/dist/router.cjs.js:3703:19)
at async loadRouteData (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/router/dist/router.cjs.js:3678:19)
at async queryImpl (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/router/dist/router.cjs.js:3523:20)
at async Object.queryRoute (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/router/dist/router.cjs.js:3489:18)
at async handleResourceRequest (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/server-runtime/dist/server.js:361:20)
at async requestHandler (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/server-runtime/dist/server.js:138:18)
at async nodeHandler (/Users/otis/Developer/vtt.tools/node_modules/@remix-run/dev/dist/vite/plugin.js:841:27)
at async /Users/otis/Developer/vtt.tools/node_modules/@remix-run/dev/dist/vite/plugin.js:844:15
I think this may be a bug, or I am missunderstanding the intent of the onRedirectCallback.
Kinde docs
Remix SDK
Our developer tools provide everything you need to get started with Kinde.
7 Replies
IkiTg07
IkiTg07•3mo ago
Hey, not familar with Remix. Let me ask the team for you
chopfitzroy
chopfitzroyOP•3mo ago
Thank you so much, also let me know if there is anymore detail I can add, could probably spin up a reproducable example as well if needed.
Oli - Kinde
Oli - Kinde•3mo ago
Hey @chopfitzroy, Thanks for reaching out and sorry that you are experiencing issues with the Remix SDK.
could probably spin up a reproducable example as well if needed.
@chopfitzroy - could you please: 1. Raise a GitHub issue on the Remix SDK GitHub repo 2. Could you please add a reproducible example to the GitHub issue? This will help my Remix expert team mate reproduce and troubleshoot your issue. My Remix expert team mate constantly monitors activity on the Remix SDK GitHub repo, so once you have posted on the Remix SDK GitHub repo, my team mate will see the issue you raise. Let me know if you have any concerns on this
GitHub
GitHub - kinde-oss/kinde-remix-sdk
Contribute to kinde-oss/kinde-remix-sdk development by creating an account on GitHub.
chopfitzroy
chopfitzroyOP•3mo ago
@Oli - Kinde have created minimal repo here: https://github.com/chopfitzroy/kinde-example (have added steps to reproduce in the README). Please let me know if there is anything else I can add.
GitHub
GitHub - chopfitzroy/kinde-example
Contribute to chopfitzroy/kinde-example development by creating an account on GitHub.
chopfitzroy
chopfitzroyOP•3mo ago
Sorry also opening an issue now! Sorry forgot that bit 🫣
chopfitzroy
chopfitzroyOP•3mo ago
GitHub
Bug: user is undefined in onRedirectCallback. · Issue #19 · k...
Prerequisites I have searched the repository’s issues and Kinde community to ensure my issue isn’t a duplicate I have checked the latest version of the library to replicate my issue I have read the...
Oli - Kinde
Oli - Kinde•3mo ago
Thanks @chopfitzroy for raising this issue and passing on a reproducible example. Looks like my team mate Peter already got back to you on the GitHub issue here If you have any questions on this, I would suggest commenting on the GitHub repo and tagging Peter.
GitHub
Bug: user is undefined in onRedirectCallback. · Issue #19 · k...
Prerequisites I have searched the repository’s issues and Kinde community to ensure my issue isn’t a duplicate I have checked the latest version of the library to replicate my issue I have read the...
Want results from more Discord servers?
Add your server