Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/becem-gharbi/prisma-cloudflare
Nuxt starter on Cloudflare with auth, prisma & Naive UI
https://github.com/becem-gharbi/prisma-cloudflare
auth cloudflare nuxt prisma
Last synced: 4 months ago
JSON representation
Nuxt starter on Cloudflare with auth, prisma & Naive UI
- Host: GitHub
- URL: https://github.com/becem-gharbi/prisma-cloudflare
- Owner: becem-gharbi
- License: mit
- Created: 2024-04-06T08:33:51.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-06-09T10:27:53.000Z (8 months ago)
- Last Synced: 2024-06-09T11:32:50.740Z (8 months ago)
- Topics: auth, cloudflare, nuxt, prisma
- Language: Vue
- Homepage: https://prisma-cloudflare.bg.tn
- Size: 1.11 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Prisma Cloudflare
This project is a Nuxt starter app with auth and Naive UI using Prisma with D1 database deployed on Cloudflare pages.
Cloudflare offers a worlwide network to serve static content and run serverless code with native object storage and database binding.
Nuxt is a fullstack framework for building server-rendered Vue apps and runtime agnostic web services.
To get started building Nuxt apps on Cloudflare it's recommended to use [Nuxt Hub](https://hub.nuxt.com) platform.Prisma is an ORM that supports edge deployment either via a proxy runnig on Prisma accelerate or via driver adapters. This project uses Cloudflare D1 driver which is introduced on version 5.12.0. The limitations are:
- This feature is in currently in preview.
- The query engine is bundled with currently 782kB which limits the app size for the free tier where the server bundle size cannot exceed 1mB.
- The database migration should be made with Wrangler instead of Prisma migrate command. This project handles the migration [workflows](https://www.prisma.io/docs/orm/overview/databases/cloudflare-d1#migration-workflows) via `migrate` scripts.
## Setup
To get started you will need to have a Cloudflare account.
- Install dependencies.
```bash
pnpm install
```- Rename `.example.env` to `.env` and set env variables, check [@bg-dev/nuxt-auth](https://nuxt-auth.bg.tn).
- Deploy the project on Cloudflare Pages and add the env variables.
- Create a new D1 database and [bind](https://developers.cloudflare.com/pages/functions/bindings/#d1-databases) it to the Page project.
- Rename `ex.wrangler.toml` to `wrangler.toml` and set `database_name` and `database_id`. This will be used by Wrangler.
- Generate Prisma client
```bash
npx prisma generate
```- Apply migration on local database.
```bash
pnpm migrate:apply
```- Apply migration on remote database.
```bash
pnpm migrate:apply --remote
```- Generate new migration file after updating Prisma schema (optional).
```bash
pnpm migrate:generate
```