Description
Checklist
- I have looked into the API documentation and have not found a suitable solution or answer.I have searched the issues and have not found a suitable solution or answer.I have searched the Auth0 Community forums and have not found a suitable solution or answer.I agree to the terms within the Auth0 Code of Conduct.
Describe the problem you'd like to have solved
After the Storybook 8.1 release announcement, I was intrigued by the idea of write Storybook stories for my page components that are written with the Next.js App Router. So I started digging into the example repository that's mentioned in the blog post, and I've been digging into the code that powers the Next.js mocks that Storybook has published.
The page component that I'm attempting to write story for is wrapped with a call withPageAuthRequired
function, and I don't see any published resources for how to use or craft mocks for this library.
Describe the ideal solution
I'd ideally like to see official mocks published with this package or published in a sibling package.
Alternatives and current workarounds
I've attempted to dig into the session handling logic to see if there's a way that I can simulate a valid session by mocking the cookie access, since there is already a published mock for doing so (see example usage). However, it looks like I would need to duplicate the logic that is used to encrypt the contents of the cookie. I would rather just be able to mock whether or not someone is logged in along with the profile information that would be provided by useUser
.
Additional context
There is an additional blog post that Storybook has published which outlines the module mocking approach that they are following. All of the mocks that Storybook ships for Next can be found in that project's export-mocks
folder. I suspect that it's going to be a good resource to learn from.
Activity
arpit-jn commentedon May 27, 2025
Hello, could you please give generatesessioncookie helper function a try and let us know if this works for you? Though the example shared is for v4, it should work for v3 as well.
I hope this addresses your concerns. Please feel free to reach out if you still face this issue.