ryanwalters / amplify-auth-next-storage

Isomorphic cookie storage for Next.js apps using @aws-amplify/auth

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible to use in Higher Order Component?

cn-d opened this issue · comments

commented

Thanks for making this. I'm learning both Amplify and Next.js at the same time so please excuse me if this is misguided.

It seems my page structure does not quite suit the outlined example in the README. The structure requires only certain pages to be authenticated, specifically pages under a /admin pathname.

pages/
    index.js
    [id].js
    admin/ 
        index.js          // secured by auth
        [id].js               // secured by auth

Ideally, all pages not in /admin should be statically generated but It seems using the pages/_app.js structure prevents this. I was thinking that maybe this module, used in a higher-order component could wrap the pages that need Auth, similarly to the example in the docs. I've been struggling to get something working, do you think that this is possible?