rsnext/examples/with-tigris
Karl Horky 3ad55721d1
Remove incorrect entries for pnpm debug log (#47241)
**Reasons for making this change:**

- it is contained within `node_modules/`, which is already ignored
- the previous versions, which were not in `node_modules/`, did not have
a period at the beginning of the filename

Links to documentation supporting these rule changes:

**Changelog with proof here:**


ba4b2db1f2/pnpm/CHANGELOG.md (L3330)

History:

- my PR to remove this from `github/gitignore` here:
https://github.com/github/gitignore/pull/4250
- First introduced in `github/gitignore` in
https://github.com/github/gitignore/pull/3732 by `@sakurayang` (merged
by `@martinwoodward`)

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-26 22:26:05 -07:00
..
components refactor: Latest Tigris sdk and example using decorators (#44256) 2023-01-18 20:44:18 -08:00
db/models refactor: Latest Tigris sdk and example using decorators (#44256) 2023-01-18 20:44:18 -08:00
lib refactor: Latest Tigris sdk and example using decorators (#44256) 2023-01-18 20:44:18 -08:00
pages refactor: Latest Tigris sdk and example using decorators (#44256) 2023-01-18 20:44:18 -08:00
public Tigris example with Next.js (#42662) 2022-11-15 12:00:29 +01:00
scripts refactor: Latest Tigris sdk and example using decorators (#44256) 2023-01-18 20:44:18 -08:00
styles Tigris example with Next.js (#42662) 2022-11-15 12:00:29 +01:00
.env.development Tigris example with Next.js (#42662) 2022-11-15 12:00:29 +01:00
.env.local.example refactor: Latest Tigris sdk and example using decorators (#44256) 2023-01-18 20:44:18 -08:00
.env.production Tigris example with Next.js (#42662) 2022-11-15 12:00:29 +01:00
.gitignore Remove incorrect entries for pnpm debug log (#47241) 2023-03-26 22:26:05 -07:00
next-env.d.ts Remove incorrect entries for pnpm debug log (#47241) 2023-03-26 22:26:05 -07:00
package.json refactor: Latest Tigris sdk and example using decorators (#44256) 2023-01-18 20:44:18 -08:00
README.md refactor: Latest Tigris sdk and example using decorators (#44256) 2023-01-18 20:44:18 -08:00
tsconfig.json refactor: Latest Tigris sdk and example using decorators (#44256) 2023-01-18 20:44:18 -08:00

Tigris example app on Next.js - Todo list

A simple todo app built on Next.js and Tigris using TypeScript client, deployed on Vercel.

Project demo

https://tigris-nextjs-starter-kit.vercel.app/

⚙️ Deploying your own

All you need is a Github, Vercel and Tigris account(sign up for a free account). Now, Hit "Deploy" and follow instructions to deploy app to your Vercel account

Deploy with Vercel

🎉 All done. You should be able to use app on the URL provided by Vercel. Feel free to play around or do a code walkthrough next 🎉

Tigris integration with Vercel will automatically fetch access keys to populate Environment Variables when deploying app.

2. Running Next.js server & Tigris dev environment on your local computer

📖 Running Next.js server & Tigris locally

Prerequisites

  1. Tigris installed on your dev computer
    1. For macOS: brew install tigrisdata/tigris/tigris-cli
    2. Other operating systems: See installation instructions here
  2. Node.js version 16+

Instructions

  1. Clone this repo on your computer
git clone https://github.com/tigrisdata/tigris-vercel-starter
  1. Install dependencies
cd tigris-vercel-starter
npm install
  1. Start Tigris local development environment
tigris dev start
  1. Run the Next.js server
npm run dev

Note: This step uses a custom dev & build script to initialize Tigris collections for the app and requires ts-node to be installed.

🎉 All done. You should be able to use app on localhost:3000 in browser. Feel free to play around or do a code walk-through next 🎉

📖 How to use

Execute create-next-app with npm, Yarn, or pnpm to bootstrap the example:

npx create-next-app --example with-tigris tigris-next-app
yarn create next-app --example with-tigris tigris-next-app
pnpm create next-app --example with-tigris tigris-next-app

Deploy it to the cloud with Vercel (Documentation).

👀 Code walkthrough

📂 File structure
├── package.json
├── lib
│   ├── tigris.ts
├── db
│   └── models
│       └── todoItems.ts
└── pages
    ├── index.tsx
    └── api
        ├── item
        │   ├── [id].ts
        └── items
            ├── index.ts
            └── search.ts
🪢 Tigris schema definition

db/models/todoItems.ts - The to-do list app has a single collection todoItems that stores the to-do items. The Collection gets automatically provisioned by the setup script.

🌐 Connecting to Tigris

lib/tigris.ts - Loads the environment variables you specified previously in creating a Vercel project section and uses them to configure the Tigris client.

❇️ API routes to access data in Tigris collection

All the Next.js API routes are defined under pages/api/. We have three files exposing endpoints:

pages/api/items/index.ts

  • GET /api/items to get an array of to-do items as Array
  • POST /api/items to add an item to the list

/pages/api/items/search.ts

  • GET /api/items/search?q=query to find and return items matching the given query

pages/api/item/[id].ts

  • GET /api/item/{id} to fetch an item
  • PUT /api/item/{id} to update the given item
  • DELETE /api/item/[id] to delete an item

🚀 Next steps

In a few steps, we learnt how to bootstrap a Next.js app using Tigris and deploy it on Vercel. Feel free to add more functionalities or customize App for your use-case and learn more about Tigris data platform