3 ms·
This is the best way to get Python devs to start using JavaScript. But if you're already writing in JavaScript (or TypeScript), why wouldn't you want to re-use
by chatmasta 4y ago
This is the best way to get Python devs to start using JavaScript. But if you're already writing in JavaScript (or TypeScript), why wouldn't you want to re-use the code on server and client? Next.js is basically modern day PHP - you create a file in /pages/foo/bar.ts and it renders at localhost:3001/foo/bar. It really doesn't get much easier than this, and anyone complaining about it has likely not tried it or doesn't have a green field project where they can start from scratch with TypeScript and Next.js.
Also, this trope that "JavaScript can only render websites that require JavaScript to read" is a common misconception. Next.js, for example, is perfectly capable of rendering websites that work for clients with JavaScript disabled. In fact, that was kind of the original point of SSR: to make websites that search crawlers could read by processing the HTML sent from the server. The server renders the initial page, and then the client (optionally, if following best practices) "hydrates" the DOM to render any further content that requires client-side interaction (indeed, it's bad practice to require hydration, and a mismatch between server rendered DOM and hydrated DOM will generate warnings in development).