Thanks for a great talk on Next.js Conf about Personalization and Edge Middleware (unfortunately it’s unlisted) and for this stream about Edge with Vercel and Builder:
Our main question is:
Is it possible to use Next.js Edge Middleware outside of Vercel Edge Network?
If yes, can you share any examples, links, articles, docs on how to do this?
We currently run Next.js 12 App with Builder.io and Custom build components.
The App runs on GCP Cloud Run.
We would like to add personalization (Builder custom targeting with user-specific data, like isAuthenticated, isClubMember) and Builder A/B testing.
But we don’t want to use SSR to get user data on the server (we use Static and ISR for performance). AFAIK we can use Edge Middleware to get user-specific data before the request will reach our App and manipulate the request in a way that will allow our App to serve a specific version of the page to specific users, for example by running:
builder.setUserAttributes({
isLoggedInUser: true
});
We have found your example on github:
And some examples from Next.js:
But I can’t find information if it’s possible to run Edge Middleware on GCP or to use Vercel’s Edge Network for Edge Middleware but keep our app on GCP.
All articles and examples are about deploying it on Vercel.
I have found a tweet about running Edge Middleware on CloudFlare and this article about Netlify’s Next.js Advanced Middleware
: Next.js Advanced Middleware: On the better runtime by Netlify
So I guess if it’s possible on CloudFlare and Netlify it should be also possible on GCP. But can’t find any details
All help is highly appreciated!
Lucas