teable/apps/nextjs-app
tea artist ed056d63ce
feat: inject dynamic env to next (#392)
* fix: auto disable template entry

* feat: inject dynamic env to next
2024-03-04 00:21:30 +08:00
..
config/tests chore: rename (#356) 2024-01-30 22:20:05 +08:00
e2e/pages chore: rename (#356) 2024-01-30 22:20:05 +08:00
public refactor: change projection from obj to array (#387) 2024-03-01 13:11:10 +08:00
src feat: inject dynamic env to next (#392) 2024-03-04 00:21:30 +08:00
.env
.env.development fix: field list incomplete (#361) 2024-02-03 12:45:20 +08:00
.env.example feat: inject dynamic env to next (#392) 2024-03-04 00:21:30 +08:00
.env.test fix: field list incomplete (#361) 2024-02-03 12:45:20 +08:00
.escheckrc
.eslintrc.js chore: rename (#356) 2024-01-30 22:20:05 +08:00
.gitignore
.size-limit.js
babel.config.backup.js
CHANGELOG.md chore: rename (#356) 2024-01-30 22:20:05 +08:00
components.json
lint-staged.config.js chore: rename (#356) 2024-01-30 22:20:05 +08:00
next-env.d.ts
next-i18next.config.js chore: rename (#356) 2024-01-30 22:20:05 +08:00
next.config.js chore: update scp 2024-02-29 10:39:56 +08:00
package.json feat: guide (#386) 2024-03-01 18:38:53 +08:00
playwright.config.ts
postcss.config.js
README.md chore: rename (#356) 2024-01-30 22:20:05 +08:00
sentry.client.config.ts
sentry.server.config.ts
tailwind.config.js chore: rename (#356) 2024-01-30 22:20:05 +08:00
tsconfig.eslint.json
tsconfig.json chore: rename (#356) 2024-01-30 22:20:05 +08:00
tsconfig.scripts.json
vitest.config.ts

The web-app

build

Intro

Basic demo nextjs nextjs-app, part of the teable.

Quick start

For rest/api database access be sure to start docker-compose up main-db, see detailed instructions (seeding, docker, supabase...) in the @teable/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.

  • Api routes: some api routes for rest.
  • I18n: based on next-i18next

Monorepo deps

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

{
  dependencies: {
    "@teable/sdk": "workspace:*",
    "@teable/db-main-prisma": "workspace:*",
    "@teable/ui-lib": "workspace:*",
  },
}

And their counterparts in tsconfig.json

{
  "compilerOptions": {
    "baseUrl": "./src",
    "paths": {
      "@teable/ui-lib/*": ["../../../packages/ui-lib/src/*"],
      "@teable/ui-lib": ["../../../packages/ui-lib/src/index"],
      "@teable/sdk/*": ["../../../packages/sdk/src/*"],
      "@teable/sdk": ["../../../packages/sdk/src/index"],
      "@teable/db-main-prisma/*": ["../../../packages/db-main-prisma/src/*"],
      "@teable/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)
    ├── sdk
    ├── main-db-prisma
    └── ui-lib

Develop

$ yarn dev