How to make SSR with Adonis + React or Next?


#1

SSR is important to build a quick running app.How to implement this with Adonis?


#2

Hey @razvacos! :wave:

What have you tried so far?


#3

I found a solution with express + pug + react and saw that is another option for making ssr with headless chrome.I try to figure out a way to implement with adonis.


#4

Your backend shouldn’t care about which frontend you use. Same goes for your frontend that doesn’t care about your backend.

You should have two application and not try to merge two differents contexts.

  • Run a Next.js application (SSR)
  • Run an Adonis application (API)

#5

Ok , but how to configure Adonis with Next? Just make two separate folders and that’s it?


#6

Yes, they aren’t related and aren’t the same application.
Two folders, two different ports, two different apps.


#7

Do you have an example?


#8

Why would you need an example?

adonis new myApi --api-only
create-next-app myFrontend

#10

Would be awesome a showcase on github or an article…


#11

I don’t think it’s needed. As I already said, it has nothing to do with Adonis.
You need to understand both serve a different context and use-case.

  • Your API is used to serve data.
  • Your frontend is used to get the data from the API via an HTTP call.

#12

I asked because want to use this package :


with Adonis api.


#13

@romain.lanz no need Express.js side by side with Adonis.js?


#14

Hi @razvacos

There is a service provider for Nextjs

and for quick start or how to run it, check this repo


#15

Thanks for your reply.
Now i’m migrating to Apollo graphql client instead of Next.js.