Re:Building the Same App Using Various Web Frameworks
by 9dev on Wednesday September 11, 2024 @01:02AM
(#41508154)
In SvelteKit (don’t know about Next.js), this also makes for a nice, gracefully degrading JS-enabled form experience for the user, while always also working for those running script-less. You’ll automatically get partial validation, loading states, error handling, and so on, as opposed to API routes where you’ll need to do that on your own.
Re:Building the Same App Using Various Web Frameworks
by TmpstsTrrctta on Thursday September 12, 2024 @01:42AM
(#41517910)
I had success in a project using Sapper, a precursor to SvelteKit, with using an early version of this called server routes. On server routes, you could define a JSON api which could also have its data statically exported.
On the other hand, I’ve seen server actions abused in large production apps leading to lots of sprawl when handling similar data patterns. Everything becomes an action and it becomes difficult to update the system cohesively or get data externally.
I do feel there could possibly be a bit more magic with Server Actions to generate actual API endpoints. I’m a fan of FastAPI’s handling of pulling path and body variables into an endpoint, typing the params and then accessing them in Next.js on the other hand feels more burdensome. I could very well just be not using it correctly.
- https://nextjs.org/docs/app/building-your-application/data-f...
- https://kit.svelte.dev/docs/form-actions