Skip to content

Files

Latest commit

bc4cc2c · Oct 12, 2022

History

History
This branch is 4165 commits behind belgattitude/nextjs-monorepo-example:main.

nextjs-app

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Oct 9, 2022
Oct 3, 2022
Apr 22, 2022
Oct 3, 2022
Sep 17, 2022
Sep 17, 2022
Apr 11, 2022
Sep 30, 2022
Apr 9, 2022
Sep 17, 2022
Oct 7, 2022
Apr 9, 2022
Sep 15, 2022
Jul 2, 2022
Oct 2, 2022
Sep 15, 2022
Apr 9, 2022
Apr 25, 2022
Sep 17, 2022
Oct 12, 2022
Aug 12, 2022
Apr 9, 2022
May 30, 2022
Apr 9, 2022
Jun 15, 2022
Sep 30, 2022
Oct 3, 2022
Aug 18, 2022

The web-app

build

Intro

Basic demo nextjs nextjs-app, part of the nextjs-monorepo-example.

Quick start

For rest/api database access be sure to start docker-compose up main-db, see detailed instructions (seeding, docker, supabase...) in the @your-org/db-main-prisma README.

$ yarn install
$ cd apps/nextjs-app
$ yarn dev

Features

Some common features that have been enabled to widen monorepo testing scenarios.

Monorepo deps

This app relies on packages in the monorepo, see detailed instructions in README.md

{
  dependencies: {
    "@your-org/core-lib": "workspace:*",
    "@your-org/db-main-prisma": "workspace:*",
    "@your-org/ui-lib": "workspace:*",
  },
}

And their counterparts in tsconfig.json

{
  "compilerOptions": {
    "baseUrl": "./src",
    "paths": {
      "@your-org/ui-lib/*": ["../../../packages/ui-lib/src/*"],
      "@your-org/ui-lib": ["../../../packages/ui-lib/src/index"],
      "@your-org/core-lib/*": ["../../../packages/core-lib/src/*"],
      "@your-org/core-lib": ["../../../packages/core-lib/src/index"],
      "@your-org/db-main-prisma/*": ["../../../packages/db-main-prisma/src/*"],
      "@your-org/db-main-prisma": [
        "../../../packages/db-main-prisma/src/index",
      ],
    },
  },
}

API routes

Rest api

Try this route http://localhost:3000/api/rest/poem

Graphql (sdl)

In development just open http://localhost:3000/api/graphql-sdl to have the graphiql console.

Try

query {
  allPoems {
    id
    title
  }
}

Some tips

I18N & typings

Translations are handled by next-i18next. See the next-i18next.config.js. The keys autocompletion and typechecks are enabled in ./src/typings/react-i18next.d.ts.

Structure

.
├── apps
│   └── nextjs-app
│       ├── public/
│       │   └── locales/
│       ├── src/
│       │   ├── backend/*     (backend code)
│       │   ├── components/*
│       │   ├── features/*    (regrouped by context)
│       │   └── pages/api     (api routes)
│       ├── .env
│       ├── .env.development
│       ├── (.env.local)*
│       ├── next.config.mjs
│       ├── next-i18next.config.js
│       ├── tsconfig.json    (local paths enabled)
│       └── tailwind.config.js
└── packages  (monorepo's packages that this app is using)
    ├── core-lib
    ├── main-db-prisma
    └── ui-lib

Develop

$ yarn dev