wolfiton

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

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

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”:

  1. Content is the foundation
  2. Markup is an Enhancement (HTML)
  3. Visual Design is an Enhancement (CSS)
  4. Interaction is an Enhancement (ECMAScript)
  5. 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

mhanberg

Expert LSP Core Team

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

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.

Where Next?

Popular in Questions Top

Kurisu
For example for a current url like http://localhost:4000/cosmetic/products?_utf8=✓&query=perfume&page=2, I would like to get: ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 126479 1222
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement