wolfiton
Can Phoenix api be integrated directly into NEXTJS?
Can the Phoenix api be used directly with NEXTJS without a node server?
If not does the node server add delays to requests?
Also the example folder that NEXTJS offer for supported servers so far
Thank you in advanced
Marked As Solved
peerreynders
SSR because I want to have offline support
SSR isn’t a prerequisite for offline support.
Offline support is accomplished via Service Workers. Now in the simplest case a Service Worker can cache responses which could be rendered pages but client side JavaScript can be cached as well. With an SPA you would tend to also use IndexedDB (with Promises) to stash some data for offline use.
Have a look at
Progressive Web Apps: Going Offline | Google for Developers
Gemini-powered solutions | Google for Developers
https://youtu.be/psB_Pjwhbxo?list=PLNYkxOF6rcIB2xHBZ7opgc2Mv009X87Hh
Also Liked
peerreynders
As far as I know server rendered pages are preferred for SEO. And while Google can process some JavaScript they only recently switched from Chrome 41 (2015) to 74.
This might be a good starting point for understanding some of the issues:
https://www.onely.com/blog/ultimate-guide-javascript-seo/
A PWA doesn’t need to be an (SSR) SPA (the App Shell Model created this confusion) - it is entirely possible to build a PWA where the page is rendered with EEx - but it’s the responsibility of the JS delivered with those pages to enable the PWA functionality on the browser end:
… that doesn’t automatically imply SPA. PWAs are supposed to extend “Progressive Enhancement”:
- Content is the foundation
- Markup is an Enhancement (HTML)
- Visual Design is an Enhancement (CSS)
- Interaction is an Enhancement (ECMAScript)
- Network is an Enhancement (Offline first)
https://love2dev.com/blog/pwa-spa/
https://love2dev.com/blog/yes-fast-food-frameworks-cost-too-much/
https://love2dev.com/blog/large-javascript-frameworks-are-like-fast-food-restaurants/
mhanberg
I believe you will always need a server that will run the Next.js server (this is a Node app).
If you then want an API (Phoenix in this case), you will need to run your Phoenix server in addition to the Next.js server.
peerreynders
From:
def index(conn, _params) do
component_path = "#{File.cwd!}/assets/js/HelloWorld.js"
props = %{name: "Revelry"}
{ :safe, helloWorld } = ReactRender.render(component_path, props)
render(conn, "index.html", helloWorldComponent: helloWorld)
end
And
https://github.com/revelrylabs/elixir_react_render/blob/master/lib/react_render.ex#L92-L110
So it looks to me that Node.js is rendering the React content but the phoenix controller is serving the rendered content - i.e. Node.js is rendering but not serving (but I haven’t looked much deeper in to it).
By the looks of things elixir-nodejs communicates with Node.js processes via ports.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








