New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Survey app router migration #1738
Comments
Cool, this was a fun first swing of the axe tonight. It led to 41f6b4c, which I won't even put into a draft PR yet as there's no clear target branch until the work #1636 and #1719 coexist in a single branch. The need for the new I've left the POST request handling code completely behind for now. I suspect it's relatively easy to port to a route handler and that we'll be able to throw away that request parsing code too 1. The interesting problems here are in the Material UI & Emotion part of town. Here's the latest error when you hit http://localhost:3000/o/1/surveys/20 @ 41f6b4c. Going to hit pause on this for tonight, so here's a little snapshot of the kind of stuff I've been browsing while researching how to fix this one.
Copilot's suggested trying one of those webpack config resolve alias hacks in Footnotes |
Updating This produced an
All the above eventually produced 9153a7f. This is really rough work here. Poke around in that diff and you'll see I've hardcoded the intl props to placeholder values for example. I just wanted to punch through to the finish line with this one and kind of try to expose more of the surface area of the problem. Here's a screenshot of the app router version of the survey page rendering "successfully" using real API data. Going to hit the brakes again for the night cos this is such a lovely milestone. Going to braindump some of the loose ends first:
|
Renamed
|
Today I've dealt with the hardcoded If you'd like to read dozens and dozens of frustrated comments begging Vercel to reinstate access to the request object, check out vercel/next.js#42732. Guess they have some kind of grand vision here. Presumably abstracting away the request object like this enables some kind of edge function magic. Whatever. Ours not to reason why. They have an FAQ entry about this too. Went back and forth a few times about the right way to do this. In the end I just opted for the approach that produced the smallest possible diff. I know it's a bit ugly having a function whose argument type is |
Hey cool, big milestone: in 691d178 I've commented out the
This means that the next step here will be the route handler for the POST request! |
Okay, feac52e has one possible approach to handling survey form submissions via the app router. Unfortunately it breaks the noscript version of the form. I'm not happy about this at all, but it seems to be the direction Vercel's taking Next.js whether we like it or not. In the request object discussion I linked earlier, a couple of the threads cover this very topic.
In that second one, one of the Next.js team claims progressive enhancement is still possible with the app router if you also adopt server actions. The community member then attempted to explore that suggestion, without success. And if you dig a layer deeper by clicking on some of the links in the docs for this functionality, you notice it's using stuff like My intuition's telling me server actions are a bit too bleeding edge for Zetkin's purposes right now. So that leaves options like feac52e, where we intercept the form submit event and hand it off to an |
Commit 3989273 contains a working server action. The trick was to move the server action definition into its own file. Due to the function no longer being defined in a scope where The Next.js docs say you can inline server actions as long as you put |
Closing this now as today's hackathon progress enables us to consolidate these efforts into #1756 rather than continuing with multiple parallel threads of development. |
Going to drop a quick summary of the survey app router migration thing here before getting started as it's been a long week since this was all discussed and it's at risk of getting forgotten completely unless it's captured in writing now!
#1718 includes the Next.js app router. Once that issue's closed, it'll be possible to begin using the App Router for Zetkin functionality. A clear first use-case for that is the new version of the survey.
Previously the survey's needed people to log in in order to fill it in. It's now become desirable to remove that limitation.
This is also a convenient first step for the overall app router migration. That's because the
scaffold()
function that all the page router code uses will need to become something quite different for app router code, which means it's nicer shaping new solutions (such as allowing access to a feature like this without requiring login) around the new API instead of the old one.The text was updated successfully, but these errors were encountered: