https://supertokens.com/ logo
Title
b

brettshep

02/22/2023, 3:30 PM
Hi, just discovered SuperTokens and it looks really great, but I'm working with a Nuxt 3 app and am struggling to implement it. Is there any tutorial or examples of anyone doing this successfully?
r

rp

02/22/2023, 3:31 PM
hey @brettshep we don't have an example with nuxt3, but if you are using us with our pre built UI, then checkout the vue code tabs, else checkout the use your own UI section.
and if you have any specific questions, please feel free to ask.
b

brettshep

02/22/2023, 3:34 PM
sure, I guess the first thing I noticed on the backend is that there's no option for h3, only express middleware. Wasnt sure how to translate that over. I was trying to follow the Next.js tutorial in hopes that it would be somewhat applicable
r

rp

02/22/2023, 3:35 PM
yea.. we have an open PR for support wit h3: https://github.com/supertokens/supertokens-node/pull/477 You can feel free to pick it up from there and add it to the sdk 🙂
b

brettshep

02/22/2023, 3:41 PM
thanks! I'll look into this and see how it goes
so looking at the pull request, I was trying to implement the middleware, but how do i get access to the getInstanceOrThrowError function. Is there anyway to get that from the supertokens-node library?
I was trying to avoid modifying the underlying supertokens library, but ddint know if it's possible
r

rp

02/22/2023, 6:17 PM
Yeaaaa. It is possible if you import via the supertokens-node/lib/build/* path, but I wouldn’t recommend it.
b

brettshep

02/22/2023, 6:18 PM
hmm, I wanted to avoid modifying the library so I could stay up to date for security reasons, but maybe i dont have a choice
r

rp

02/22/2023, 6:19 PM
Yea modifying would be the best way and we could merge it it. But you could also create your own request / response objects which conform to the BaseRequest and BaseResponse classes in our SDK, and then pass that into the middleware and getSession function calls. That would work as well
b

brettshep

02/22/2023, 7:11 PM
I saw this comment on the pull request
Our SDK cannot depend on these functions cause we can't add dependency on h3 in our package.json (but we can in dev dependencies - which you already have). Is there a way in which these functions can be called directly on the H3Event object?
From what I've gathered it's not possible to call these functions directly from the event object. You'd basically have to copy the code directly from h3 if you can't have it as a dependency.
the attached photo was an example of how h3 implemented their sendError fn
r

rp

02/22/2023, 9:33 PM
Well then what we can do is to conditionally require from h3. So if a user is using supertokens with h3, the conditional require will work, else not.