Any more in-depth examples of this outside of the one previously posted?
Which one were you talking about that was previously posted, so we make sure not to give you the same one again?
https://github.com/mottox2-sandbox/next-on-netlify is the one I was referring to.
That example is the only one I am aware of. I see that Swyx posted that repo in this topic:
However, that repo was created by a third-party, not someone at Netlify. To clarify: Swyx is here at Netlify but the creator of the repo is not.
I am not aware of other examples of using Next.js 9 on Netlify. If you find out more about this, please feel free to add that information here.
Fellow NextJS- and Netlify-fan here!
I’ve been looking for a way to bring serverless NextJS to Netlify for a while. And I’m very happy to share that I’ve found a solution!
I’ve packed that solution up into a small npm package called
next-on-netlify. It’s just a compatibility wrapper for hosting NextJS apps on Netlify. Check out this Medium article on getting started in 5 quick steps.
Basically, the package does three things:
- Copy each NextJS pages into either the
publicdirectory (if it uses
.getInitialPropsand does not need to be SSRed) OR the
functionsdirectory (if it uses
.getInitialPropsand does need to be SSRed)
- Create a Netlify function called
nextRouterthat is responsible for server-side rendering those pages that use
- Set up a Netlify
_redirectsfile and proxy all requests for SSR pages to the
You can check out a demo here: next-on.netlify.com/
And you can check out the main script of the package here: https://github.com/FinnWoelm/next-on-netlify/blob/master/next-on-netlify.js
Let me know what you think, whether you run into any issues, any ideas for improvements, etc… And if you end up building anything with
next-on-netlify, I would love to hear about it, too
Hi, @finn.woelm, welcome to our Netlify community site and wow! Wow and thank you!
This is an incredibly helpful contribution. Thank you for creating it and for sharing what you created here with the community.
It would be wonderful if people that experiment with and use this package would share their thoughts about it here as well. Please feel free to make comments about this below (and/or to create a new topic to discuss specific issues).
This is fantastic! Thanks again.