Live data from Hacker News

Write PHP Code Within Next.js Components

github.com

11–20 of 107 posts

Re: Write PHP Code Within Next.js Components

#13

I hope with enough joking around the Next.js team realizes they've made a horrible mistake. What they should have done was include a convenient RPC framework in Next - not magic code-splitting and magic RPC code-gen built specifically for people that are too lazy to write two files for code ran in completely different environments.

The Next team's core use case is a serverless framework for Vercel. Anyone looking to use it as a long-running server is just a second-class citizen.

Re: Write PHP Code Within Next.js Components

#16
I think part of what makes these recent gags so funny to me is that it illustrates how perilous mixing RSC with client code feels in practice. Worrying about teammates accidentally exposing environment variables was already bad enough. Debugging is now even more troublesome, and for what? So we can use some XML-like syntax everywhere? React serves a purpose but this doesn't feel like it. All these directives, the lookalike tree complexity, and overloading fetch just feels wrong.

Re: Write PHP Code Within Next.js Components

#17
It's funny, but all you see here and on Twitter are cheap shot one liners, many of these people have never even used Next.js.

I find server actions combined with RSC to be incredibly useful and powerful. Easily define and call a type safe function from client to server with zero overhead. No API boilerplate, fetch, tRPC anything.. You just define a function and call it, very nice. Type safety, code completion, refactoring works across client/server, all that.

Of course the examples of server side code in client side function handlers are just that, examples, not the suggested way to use server actions. You can write super hacky 'bad' code in every language. Server actions are best defined in their own file of course.

Not sure why it's being compared to PHP so hard as PHP is a backend only SSR framework, while Next seamlessly transfers the components/code/state to the client so you can continue re-rendering with the same framework and language client side as you used server side for SSR. PHP could never do that.

The closest thing to server actions in PHP is Livewire, which was never a standard part of PHP and not unique to PHP either. Most PHP apps just use normal JS libraries for interfacing with the server.

Re: Write PHP Code Within Next.js Components

#18

It's funny, but all you see here and on Twitter are cheap shot one liners, many of these people have never even used Next.js. I find server actions combined with RSC to be incredibly useful and powerful. Easily define and call a type safe function from client to server with zero overhead. No API boilerplate, fetch, tRPC anything.. You just define a function and call it, very nice. Type safety, code completion, refact…

They're really cool, and act like the best parts of PHP. I actually miss the simply powerful aspect of the paradigm.

Re: Write PHP Code Within Next.js Components

#19

It's funny, but all you see here and on Twitter are cheap shot one liners, many of these people have never even used Next.js. I find server actions combined with RSC to be incredibly useful and powerful. Easily define and call a type safe function from client to server with zero overhead. No API boilerplate, fetch, tRPC anything.. You just define a function and call it, very nice. Type safety, code completion, refact…

i just wanna add here on a serious note that i also see a use cases for "server actions", but i do not primarily write next.js or react so i didn't have an opportunity to try them out yet.

I think it's important to know what you would use them for. I don't think core business logic should be there, but I see why you would use them for f.e. signing something that would require a secret you don't want to have on the client side.

I do however think that it's not a good idea to show the inline code example in a presentation. fortunately none of those examples exist in the documentation. having a seperate file with server actions that can be imported is a good way to handle it i think.

Re: Write PHP Code Within Next.js Components

#20
> I hope I don't have to say this but: If you even in the slightest consider to use this in any application at all you are an absolute madman and and should be locked out of the internet for the rest of your life, I hope you find some other fun activity, maybe gardening or woodwork.
Post reply on HN