We recently wrote up a guide on getting started with the TERN stack, but we realize that some people prefer tutorials in video format. So, we've put together a short (4-minutes and 22-seconds) tutorial video on getting started with the TERN stack. You can also find the transcription below the video.
Video: Get started with the TERN stack
- π» Get started with the TERN stack GitHub template
- π Read the introduction to the TERN stack and how to migrate from MERN to TERN
- π― Find out more about Tigris
What is the TERN stack?
TERN is a technology stack consisting of:
- Tigris: an open source Serverless NoSQL Database and Search platform
- Express.js: a super-popular Node.js server
- React: one of the most popular front-end libraries on the web
- Node.js: A JavaScript runtime
For more information check out the introduction to the TERN stack.
Get started with the TERN stack - transcript
In this video, we'll demonstrate the simplest way to get started with the TERN stack.
So what is the TERN stack? TERN is an evolution of MERN. MERN is an acronym of "M" for MongoDB, "E" for Express.js, "R" for React, and "N" for Node.js. In the TERN stack we simply replace MongoDB with Tigris, converting MERN to TERN.
But why would you want to use Tigris or even replace MongoDB with Tigris? Here are just a few reasons:
Tigris takes a code-first approach to database schema modeling and search index modeling
Tigris supports database branching which fits nicely into any developer workflow
Tigris supports ACID transactions without the caveats you'll find with MongoDB
Tigris is a unified data developer platform exposing database and search capabilities through a single platform
Tigris has been built on a modern cloud-native architecture which means that running Tigris or using Tigris Cloud is cheaper than MongoDB
Now that we understand what the TERN stack is and the benefits of Tigris, we can get started with the TERN stack using the TERN stack template.
Head over to the TERN stack template on GitHub, click on use this template and create a new repository. Give your repository a name and click the "create repository from template" button. That will generate a repository for you, based off of the TERN stack template.
Click on the "code" drop-down and copy the URL for the GitHub repo. Head over to your terminal and clone that repo locally. [Music] And navigate into the directory created for that repo.
Next, let's install the dependencies for the workspace. The minus "ws" flag indicates we're installing dependencies for all the packages in that repo.
Next, we'll run the npm script "tigris:init". This is defined in the top-level package.json file and takes a flag "project" with the name of the Tigris project to be created. This npm script uses the Tigris CLI which authenticates itself with Tigris Cloud and then creates the project in Tigris Cloud. The final piece of magic performed by the "tigris:init" script is create an ".env.local" file containing your Tigris project configuration. This is copied to the apps server directory and used by the Express.js application in the TERN stack app.
With the code dependencies and config in place, we can first run the client application using "npm run dev" and the "-w" flag pointing to the TERN app client application
And then, run the Express.js server application with "npm run dev" minus "w" equals TERN app slash ("/") server. Executing "npm run dev" on the server runs a setup script which synchronizes the application's data model defined in TypeScript with Tigris.
We can now launch the React application in the web browser. In this application clicking will create a star in the user interface, and that star is represented in the Tigris database as a document with various attributes, including some that encapsulate the location of the click.
You can now log into the Tigris web console, find your Tiger's project, head to the database section, [Music] look at the database schema [Music], and also explore the data that's been stored. Here you can see various event documents that have been stored with attributes, including event data that has the URL and the click X and Y position.
We can now navigate back to the application, where clicking on an existing star will remove it. If we head back to the console and refresh, you'll see the documents representing those stars have disappeared.
We can head back to the application and add some new stars. Then go back to the Tigris console and refresh [Music], and we'll see the new stars represented as documents in the "events" collection.
You now have your TERN stack app up and running, and it's over to you... [Music].
Top comments (0)