r/nestjs • • Sep 22 '26

Can NestJS become a full-stack framework?

After my previous post about a more integrated NestJS + React approach, I got a lot of interesting feedback and questions, so I thought I’d finally share what I’ve been building.
nest-can-react is a package that lets you add React-based full-stack capabilities to an existing NestJS application.
The idea is simple:
Keep NestJS as the core. Add React as the UI layer.
Instead of treating NestJS and React as two completely separate applications, nest-can-react explores what it would look like if they could live much closer together while still taking advantage of Nest’s architecture.
It currently explores things like:
React Server Components
Client components with 'use client'
SSR
NestJS routing and dependency injection
A unified build/development workflow
This is still an early experiment, and I’m looking for honest feedback from people who actually use NestJS.
Would you use something like this? What would you expect from it?

GitHub:nest-can-react

6 Upvotes

21 comments sorted by

3

u/canarydev Sep 22 '26

docs say "Controllers pass data in; they do not inject Nest providers into those files"

so server components can't touch Nest DI at all? they just receive serializable props from the controller?

i was interested because i thought the pitch was "Nest DI inside React", and that would have been the genuinely interesting part. without it this feels closer to inertia with streaming

2

u/Fit-Woodpecker5308 Sep 22 '26

First I introduced that but there was a risk of bypassing Guards , DTOs and middleware and page was easily able to talk directly with providers so I removed that.

1

u/Fit-Woodpecker5308 Sep 22 '26

Although would love any contributions from your side.

9

u/josephanyaa Sep 22 '26

no, please. leave it the way it is. thank you and God bless

14

u/Mental-Abrocoma-5605 Sep 22 '26 edited Sep 22 '26

Dont see the need to, at best it can add templates but dont see why it should add them

Plus NestJS Is the backend equivalent of Angular, if it works directly with a frontend framework, should be with Angular (and this Is coming from someone who prefers React)

Honestly I'm More concerned for when they are going to add an unique icon for Angular/Nest to the *.dto.ts files with the Material Icon Theme extension

7

u/micalevisk Sep 22 '26

Can you do that with fastify or expressjs? Yes, then you can do that with nestjs

Should you do that? I dont think so

1

u/joelwillseek Sep 23 '26

Its underlying arch is expressjs so i think you can use ejs or pug to make some thing like php but it going to be weird and tough

1

u/Fit-Woodpecker5308 Sep 23 '26

I don’t think I need to make this like php

1

u/Due_Hovercraft_2184 Sep 23 '26

It's maybe handy as a package for users that actually want it, but it's not something I would want to see in core - especially since ssr has been such an attack vector.

It's easy to spin up with Vite and use whatever communication you like, be that rest / graphql / trpc / sse / ws.

And usually I deploy frontend and backend separate, and have a lot more env credentials I'm bothered about on the be - the separation is a feature imho

And testing / compilation is very different for browser, it will add a lot of bloat (and the associated attack surface)

2

u/Fit-Woodpecker5308 Sep 23 '26

It was an experiment 😅 I wanted to test how full stack nest will work

1

u/Due_Hovercraft_2184 Sep 23 '26

experiments are 👍 just answering your question :D

There's certainly room for a package and I can see why some people would like it, especially for quick POCs

Just suggest keeping intentionally decoupled and as a package, and up to date with core

1

u/Such_Particular_5516 Sep 23 '26

even without react nest can be full stack frame work you can serve html (SSR ) You just need template engine but I strongly believe that for most modern web apps, the better approach is to keep the API (NestJS) and the frontend completely separated

2

u/Fit-Woodpecker5308 Sep 23 '26

You are also right but would love if you can check out the actual package

2

u/Such_Particular_5516 Sep 23 '26

sure buddy once I have time I will check it out

3

u/night_86 Sep 22 '26

Terrible idea at the core. Just create react app, build it with Vite and serve via ServeStatic. That’s it. Your backend is API. Your React is UI. They communicate by either OAS, gRPC or GraphQL schema - or whatever you like. They never share „common” or other abominations.

Start using established patterns, that are well documented and battle tested in thousands of apps in the world.

2

u/lenswipe Sep 22 '26

No and I don't think it should. 

Nest does one thing and does it well.

1

u/RussMatt7793 Sep 23 '26

If you want DI inside your FE why do not use Angular? It is the natural companion for NestJS applications. The learning curve is almost the same