Hi everyone, I'm looking to optimize my code with ...
# support-questions-legacy
w
Hi everyone, I'm looking to optimize my code with SuperTokens and Next.js. Since Next.js changed to App Router from Pages Router, there have been some changes to initialize SuperTokens on the frontend. I would like to use the "doesSessionExist" function on the frontend, but my SuperTokens initialization is in the layout. I just created a provider that initializes SuperTokens, and in my Middleware, I check the "sFrontToken" cookies. However, I would prefer to use "doesSessionExist" as it's more secure than a simple check of the cookies. The problem here is that the middleware is executed before my layout is rendered, so I encounter the error "Session.init() must be called before calling doesSessionExist". Can someone help me figure out a solution, please? There's my actual middleware and root layout