Next.js Discord

Discord Forum

NextJS Viability with Pre-Existing Backend

Unanswered
Masai Lion posted this in #help-forum
Open in Discord
Masai LionOP
Hello,

I am trying to make a new project - however the app is 100% interactive and there are no static parts of the app other than the admin dashboard.

I already have a backend made in Rust with Actix, and I was wondering if using NextJS was a good idea when I already have a backend - or if using something else like just React using Vite would be a better option?

Thanks.

58 Replies

Cretan Hound
You can use React and Vite however you would probably enjoy the benefits of NextJS other than the backend, for example the Image optimizations and whatnot...
nextjs will work great
treat your backend like an api
@linesofcode nextjs will work great
Masai LionOP
Right, ok. With the amount of dynamic-ness that my app will need - will it not become a chore using Next having to do e.g. "use client" in almost everything?
it will not
Cretan Hound
you can use client in the parent component and the children will automatically be client components (I believe)
@Cretan Hound you can use client in the parent component and the children will automatically be client components (I believe)
Masai LionOP
That's not true iirc, I know for a fact you can have RSCs as children of client components
(correct me if I'm wrong @linesofcode)
yep
Cretan Hound
does it not default to client though, with the ability to define server child component
@Masai Lion even if you need to add a "use client" at the top of every file
is that such a big deal?
you're building a product not optimizing the lines of code in your codebase
Masai LionOP
I guess not, but then am I not just sacrificing all/the good features of Next?
nope
Cretan Hound
you still gain the benefits like I mentioned
Image optimization
you are simply using less features
Cretan Hound
SEO
Link preloading
with the option to use the entirety of it if you see fit
plus you get the great developer experience that comes with it
@Cretan Hound SEO
Masai LionOP
That's the thing as well, I don't need SEO. In fact, I don't want it. This is an app purely for my internal organisation which we will use for purely internal purposes. I don't think it will be ever looked at by anyone other than us anyway, and 100% the codebase won't be looked at by anyone other than me.
For example, I'm building a medium nextjs app and nearly all my data is coming via react-query in client side components
it works fantastic
with that said you could just use vite
and build your classic react client side app
take the path of least resistance for your use case
Masai LionOP
And this is what I was pondering.
vite will work
and nextjs will work
but if you ever decide to use extra nextjs features, like lets say an api route
or image optimization
Masai LionOP
Right, ok. Still though - what would, in my case, the benefits of using NextJS be over Vite if I don't actually want SEO etc? The app will be hosted and not accessible from anyone outside the LAN at work.
then you're kinda stuck if you choose vite
it's just a trade-off to make now
you know your app better than we do
@linesofcode then you're kinda stuck if you choose vite
Masai LionOP
Right, ok. Yeah - I don't think that won't be needed iirc.
@linesofcode you know your app better than we do
Masai LionOP
Right yeah, of course
I understand and value your input a lot - I greatly appreciate it for sure, I just don't want to start something and then have developer's remorse iykwim 😂
"One clarification is that if you nest a component that doesn't have use client, into a client component, directly, it'll be opted in to client component architecture"
"However, "use client" doesn't need to be defined in every component that needs to be rendered on the client. Once you define the boundary, all child components and modules imported into it are considered part of the client bundle."
btw "use client" doesnt mean that its 100% client side
@linesofcode btw "use client" doesnt mean that its 100% client side
Masai LionOP
Oh I know that yeah, common misconception that it is but I fully understand it just turns the component with that directive into one which would be as if it was in the pages dir... iirc
if you want to go 100% client side you need to do a dynamic import and then opt out of ssr in the options
which can be done near the root of your app
and then you basically just have your classic react app
similiar to what you'd have with vite
Masai LionOP
Right ok, but then that would just confuse me a bit if I'm being honest 😂
I guess also if I use Vite, I can just host it directly in my Actix Web API
for sure, it's definetly not the canonical way of doing things
but it is a good trick to know
Masai LionOP
Yeah, I appreciate the info for sure
Ok, well thanks a lot @linesofcode in helping me make a decision, you've been a great help.
I hope you have a lovely rest of your day!
No problem