An open API service indexing awesome lists of open source software.

https://github.com/tigrisdata-archive/tigris-trpc-nextjs

An example of using Tigris Database and Search with tRPC and Next.js
https://github.com/tigrisdata-archive/tigris-trpc-nextjs

nextjs search serverless tigris-data tigris-database trpc

Last synced: about 1 year ago
JSON representation

An example of using Tigris Database and Search with tRPC and Next.js

Awesome Lists containing this project

README

          


Typescript
Next.js
Typescript
LICENSE

# Tigris Database and Search + tRPC + Next.js

An example demonstrating the following tech stack:

- [Tigris](https://www.tigrisdata.com) - database and search
- [Next.js](https://nextjs.org/) - React-based web framework
- [tRPC](https://trpc.io) - Remote Procedure Call library that enables Type inference across client and server

And the following Tigris products and features:

- [Database Inserts](https://www.tigrisdata.com/docs/sdkstools/typescript/database/insert/)
- [Database Querying](https://www.tigrisdata.com/docs/sdkstools/typescript/database/query/)
- [Database Query sorting](https://www.tigrisdata.com/docs/sdkstools/typescript/database/query/#sort)
- [Database Query pagination](https://www.tigrisdata.com/docs/sdkstools/typescript/database/query/#pagination)
- [Search](https://www.tigrisdata.com/docs/sdkstools/typescript/database/search/)

## Development

### Prerequisites

- A [Tigris Cloud](https://www.tigrisdata.com) account
- Install the [Tigris CLI](https://www.tigrisdata.com/docs/sdkstools/cli/installation/)
- [Node.js > 18.13.0](https://nodejs.org/en/download/) installed

### Get the code and install dependencies

```bash
git clone git@github.com:tigrisdata-community/tigris-trpc-nextjs.git
cd tigris-trpc-nextjs
npm install
```

### Create your Tigris Project

Create your Tigris project and Tigris application keys, and set environmental variables.

### Setup

1. Login to the [Tigris Console](https://console.preview.tigrisdata.cloud/)
2. Create a Project called `tigris_trpc_nextjs` (or some other name if you prefer)
3. Navigate to **Application Keys**
4. Click the eye icon next to the Key with the same name as your Project
5. Create a `.env.development.local` file and copy:

- **URL** to a variable named `TIGRIS_URI`
- **Name** to a variable named `TIGRIS_PROJECT`
- **Client ID** to a variable named `TIGRIS_CLIENT_ID`
- **Client Secret** to a variable named `TIGRIS_CLIENT_SECRET`

6. Finally, add another variable called `TIGRIS_DB_BRANCH` with a value of `develop`

An example `.env.development.local` is in the repo called `.env.development.local.example`.

### Preload some data

An app with no data is no fun!

Run the following script to add some users to the database. Separate each username with a space character:

```shell
npm run add-users -- {username1} {username2} ... {usernameX}
```

For example, the following command will add four users to the database with the corresponding usernames:

```shell
npm run add-users -- leggetter ovaistariq adilansari GarrenSmith
```

Now, add some mock posts by running the following command:

```shell
npm run load-mock-data
```

### Run the app

With users and posts loaded, we can run the app:

```shell
npm run dev
```

## Contribute 🙌

Please do get involved! Issues and Pull Requests are very much sought and appreciated.

## Code of Conduct

See the [Tigris Community Code of Conduct](https://www.tigrisdata.com/docs/community/code-of-conduct/).

## More info

- [Join the Tigris Community Discord](https://www.tigrisdata.com/discord)
- [Follow Tigris Data on Twitter](https://twitter.com/tigrisdata)
- [Dive into the Tigris Docs](https://www.tigrisdata.com/docs/)
- [Visit the Tigris Data website](https://www.tigrisdata.com)