kittu
kittu

Reputation: 7018

Design structure for nextjs and nestjs inside nx monorepo with pnpm

I am planning to nextjs app on frontend and nestjs for backend inside NX monorepo using pnpm workspace.

I am confused how should I design the complete folder structure.

  1. Should I use package based repo?
  2. or Should I use integrated repo?
  3. or Should I use pnpm workspace and define the structure as "apps" and "libs" folder in pnpm-workspace.yaml and have both nextjs and nestjs app inside app folder?

Can anyone with some experience on the above tech stack can share your thoughts/inputs here

Upvotes: 1

Views: 2132

Answers (1)

WolffParkinson
WolffParkinson

Reputation: 1

It can be implemented in any of the three methods. It depends upon your use case.

Package based

It gives you flexibility in terms of dependencies. You can use different versions of dependencies based on the project. Using this an exmaple folder structure could be

  • apps
    • api
    • web
  • libs
    • utils
    • db
    • config

Integrated repo

It resolves all the dependencies and scripts automatically.

I personally go with package based repo when I know that in future i would want to add a new application to the monorepo with a different version of a dependency. Example : nextjs 12 and nextjs 13 app in the same repo.

I go with integrated repo when i have to get started quickly and not worry about dependencies. This is particularly useful for small projects

Upvotes: 0

Related Questions