The TERN stack:
- Tigris: Serverless NoSQL Database & Search platform
- Express.js: Fast, unopinionated, minimalist web framework for Node.js
- React: The library for web and native user interfaces
- Node.js: an open-source, cross-platform JavaScript runtime environment
The template has the following structure and make use of NPM workspaces:
.
├── apps
│ ├── client
│ │ ├── public
│ │ └── src
│ └── server
│ ├── scripts
│ └── src
└── packages
└── shared
└── src
The repo has the following workspaces:
@tern-app/client
inapps/client
: initially created using thereact-ts
template for vite@tern-app/server
inapps/server
: a TypeScript application using Express.js, the Node.js runtime, and Tigris.@tern-app/shared
: for code that is used in both the@tern-app/server
and@tern-app/client
To use the TERN stack template you'll either need a Tigris Cloud account or a self-hosted Tigris up and running.
Install the dependencies for all the workspaces using the following command:
npm i -ws
There's a script in ./package.json
called tigris:init
that does that for
you. It takes a --project
argument:
npm run tigris:init --project=tern-app
Use a different value to tern-app
for your Tigris project name if you like.
This will then take you through the login flow to authenticate the Tigris CLI with Tigris Cloud (by default). If you haven't already signed up, you can also go through the signup flow.
Once the CLI has been authenticated a file, apps/server/.env.local
, will be
created containing your Tigris project config.
In one terminal run:
npm run dev -w=@tern-app/client
The client will run on localhost:3000
by default.
In another terminal run:
npm run dev -w=@tern-app/server
The server will run on localhost:3001
by default.
Open the code in your favourite editor and start building your TERN app.
The client is a TypeScript React application. To learn React, check out the React documentation.
For the apps/client
workspace, you can run:
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
Builds the app for production to the dist
folder.
The server is an Express.js TypeScript application. To learn Express.js, check out the Express.js website.
Before you start the server you'll need to create a Tigris project and save the
project configuration in a .env.local
file. The top-level package.json
has a
script for that. See the Quickstart section for details.
With the Tigris project config in place you can run the server.
For the apps/server
workspace, you can run:
Runs the app in the development mode, running on http://localhost:3001.
The application will reload if you make edits.
Registers the Tigris data models with Tigris. For more info, see the Tigris data modeling with TypeScript docs.
Runs the built output from dist
.
Builds the app for production to the dist
folder.
It correctly bundles React in production mode and optimizes the build for the best
performance.
Your app is ready to be deployed!