Does anyone know whether SuperTokens can work with Server Components of Next.js 13? I'm stack on in...
e
Does anyone know whether SuperTokens can work with Server Components of Next.js 13? I'm stack on initializing SuperTokens in
app/(superTokens)/layout.tsx
which includes
'use client'
. How can I configure
setHref
handler in
frontendConfig()
without `next/router`'s
Router.push()
which causes an error? In addition,
<SuperTokensComponentNoSSR />
doesn't show anything.
n
Hi @exkazuu Maybe @porcellus can help here when hes up
p
Hi
it isn't strictly necessary to set
setHref
in the configuration, the drawback being that SuperTokens will be using full-page navigation (the next.js docs call it hard navigation). We are only doing this when navigating between auth pages (e.g.: from the email password sign in screen to the reset password screen or to the email verification screen) and when redirecting to the auth page (the user visits a protected page with an expired session)
also, can you show how you defined
SuperTokensComponentNoSSR
? are there any errors in the console? Where/how is it embedded (it may be easier just to show the entire page where it is defined/used)?
e
I now notice that how to implement API with
App Router
is different from
Page Router
(cf. https://nextjs.org/docs/app/building-your-application/routing/route-handlers). I've put the API file on
app/api/auth/[[...path]].ts
(cf. https://supertokens.com/docs/emailpassword/nextjs/setting-up-backend#2-expose-the-supertokens-apis), then it does not work. Could you help me write the API file for SuperTokens in
app
directory?
Here is the current code: https://github.com/exKAZUu/supertokens-nextjs-app-router-example https://github.com/exKAZUu/supertokens-nextjs-app-router-example/blob/main/src/app/api/auth/%5B%5B...path%5D%5D/route.ts should be fixed ... Next.js show the following errors on the console:
Copy code
X Detected default export in '/Users/exkazuu/ghq/github.com/exKAZUu/supertokens-nextjs-app-router-example/src/app/api/auth/[[...path]]/route.ts'. Export a named export for each HTTP method instead.
 X No HTTP methods exported in '/Users/exkazuu/ghq/github.com/exKAZUu/supertokens-nextjs-app-router-example/src/app/api/auth/[[...path]]/route.ts'. Export a named export for each HTTP method.
p
hi. there is no easy way to do that right now, even in our app-dir example our APIs are exposed through the page router.
e
I see. Thanks! I will use the page router. Btw, may I see your app-dir example?
e
Thanks!
I cannot start the example
next/with-emailpassword
. I've created the issue with the reproduction steps. Could you check it? https://github.com/supertokens/supertokens-node/issues/699