question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RFC: discuss value of Next.js middleware

See original GitHub issue

Next.js supports middleware, which this library could recommend as a way to integrate with next-firebase-auth. I’d like to gather input on whether middleware provides value that the current API (withAuthUser and withAuthUserTokenSSR) does not.

My initial assessment is that middleware usage could be a good option for apps where auth info is needed on many or all pages and the server-side auth/redirect settings don’t change between pages. In this scenario, middleware could provide an AuthUser on the request object in getServerSideProps or redirect as needed.

However:

  • Middleware can’t currently set return data or set React context; thus, unlike the existing API for SSR pages, AuthUser won’t be set on the client side until the Firebase JS SDK initializes.
  • Middleware reduces flexibility on whether to use auth info on individual pages.

Feedback and input appreciated!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
aprendendofelipecommented, Mar 19, 2022

Is that correct? It reads that only native Node.js APIs aren’t supported.

The problem seems to be the fs module used by the Firebase Admin SDK

1reaction
abusadacommented, Aug 8, 2022

yes, that sounds great, I would gladly prepare a pull request with the changes, I’ll try to have one ready by the end of the week

Read more comments on GitHub >

github_iconTop Results From Across the Web

RFC: Middleware · Discussion #29750 · vercel/next.js - GitHub
We propose to introduce a native capability in Next.js to define Middleware, allowing for complete flexibility of the upstream request as well as...
Read more >
middleware-upgrade-guide - Next.js
Currently, Middleware estimates whether you are serving an asset of a Page based on the Next.js routes manifest (internal configuration). This value is...
Read more >
Next.js 12.2 Overview: Middleware, Layouts, and more
Next. js 12.2 introduces stable Middleware and On-Demand ISR, experimental Edge SSR and API Routes, and more.0:00 Intro1:50 Agenda2:30 ...
Read more >
Passing variables from middleware to page in Next.js 12 new ...
"enables you to use code over configuration. This gives you full flexibility in Next.js because you can run code before a request is...
Read more >
What's New in Next.js 13 - AppSignal Blog
If you use Server Components in Next.js, you can reduce the amount of JavaScript sent to the client, enabling faster initial page loads....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found