Skip to content

SSR Support #61

@MoritzKn

Description

@MoritzKn

Is your feature request related to a problem? Please describe.
Currently, when using withPasswordProtect() the initial render will always be "return null".

https://github.com/storyofams/next-password-protect/blob/93c7ae7ead3a1322a642d02ed127fb0c85689207/src/hoc/withPasswordProtect.tsx#L53-L55

Only after the API call, the App is rendered. No matter if you are already logged in or not. This means when you are working with SSR/pages using getServerSideProps(), you can't verify that the HTML response is correct and that hydration will work in production.

Describe the solution you'd like
In theory, it should be possible to check the cookie and verify the session inside getServerSideProps().
Maybe an API could be added to perform the check in getServerSideProps() and pass the value of isAuthenticated to the ProtectedApp.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions