{"id":14971148,"url":"https://github.com/ozum/nuxt-prisma","last_synced_at":"2026-03-02T13:01:32.051Z","repository":{"id":89230640,"uuid":"607208451","full_name":"ozum/nuxt-prisma","owner":"ozum","description":"Type safe Prisma support for Nuxt.","archived":false,"fork":false,"pushed_at":"2023-03-08T13:22:25.000Z","size":211,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-04T10:16:45.032Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ozum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-27T14:36:55.000Z","updated_at":"2023-05-09T16:26:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"e2d80731-4946-4310-9559-c624e6ab7049","html_url":"https://github.com/ozum/nuxt-prisma","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"c567822fdddb445a5697304e46f7c04ceba35a09"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozum%2Fnuxt-prisma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozum%2Fnuxt-prisma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozum%2Fnuxt-prisma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozum%2Fnuxt-prisma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ozum","download_url":"https://codeload.github.com/ozum/nuxt-prisma/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240271519,"owners_count":19774859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T13:44:46.834Z","updated_at":"2026-03-02T13:01:26.989Z","avatar_url":"https://github.com/ozum.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nGet your module up and running quickly.\n\nFind and replace all on all files (CMD+SHIFT+F):\n- Name: Nuxt Prisma\n- Package name: nuxt-prisma\n- Description: My new Nuxt module\n--\u003e\n\n# Nuxt Prisma\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![License][license-src]][license-href]\n\n## Features\n\n\u003c!-- Highlight some of the features your module provide here --\u003e\n- Adds prisma client to `event.context` in the server using a Nuxt server middleware.\n- (OPTIONAL) Sets default role with `SET ROLE`.\n- (OPTIONAL) Reads an attribute from JWT and sets local role accordingly using `SET LOCAL ROLE`.\n- (OPTIONAL) Copies JWT data to the current session settings using `set_config()`.\n- (OPTIONAL) Allows a RLS implementation with options and presets. (PostgreSQL)\n- (OPTIONAL) Provides preset: `supabase`.\n\n## Quick Setup\n\n1. Add `nuxt-prisma` dependency to your project\n\n```bash\nnpm install --save-dev nuxt-prisma\n```\n\n2. Add `nuxt-prisma` to the `modules` section of `nuxt.config.ts`\n\n```js\nexport default defineNuxtConfig({\n  modules: ['nuxt-prisma'],\n  prisma: { preset: \"supabase\" }\n});\n```\n\n3. If `options.dbConfigName` or `options.jwtRoleAttribute` is used, you need to enable prisma client extensions. To use Prisma Client extensions, you must enable the clientExtensions preview feature flag in the generator block of your schema.prisma file. [Learn more](https://www.prisma.io/docs/concepts/components/prisma-client/client-extensions)\n\n```js\ngenerator client {\n  provider        = \"prisma-client-js\"\n  previewFeatures = [\"clientExtensions\"]\n}\n```\n\n## Usage\n\n**/server/api/item.get.ts**\n```ts\nexport default eventHandler(async (event) =\u003e {\n  const prisma = event.context.prisma;\n  const item = await prisma.item.findUniqueOrThrow({ where: { id } });\n}\n```\n\n## Options\n\nBelow is an example for Supabase.\n\n```ts\nexport default defineNuxtConfig({\n  modules: ['nuxt-prisma'],\n  prisma: { preset: \"supabase\" } // Options preset. Apply multiple options for a specific framework.\n});\n```\n\nSupabase preset sets options as below.\n\n```ts\nexport default defineNuxtConfig({\n  modules: ['nuxt-prisma'],\n  prisma: {\n    defaultRole: \"anon\",                // Default database role to use for unauthenticated users. Set by `SET ROLE`.\n    contextTokenAttribute: \"_token\",    // H3 event context attribute to get JWT token. WARNING: The token should be validated previously. This module does not validate JWT token.\n    jwtRoleAttribute: \"role\",           // JWT attribute to get database role from.\n    dbConfigName: \"request.jwt.claims\", // Database config name to assign contents of the JWT token. All decoded data is assigned to this config as a stringified JSON.\n  }\n});\n```\n\nExample above adds a Nuxt server middleware as explained below.\n\n|Option|Value|Description|\n|---|---|---|\n| **defaultRole** | `anon` | Sets new prisma client's role to `anon` using `SET ROLE anon` |\n| **contextTokenAttribute** | `_token` | Reads the JWT token from `event.context._token` and decodes it. |\n| **jwtRoleAttribute** | `role` | Reads `role` attribute from JWT token (i.e. `{ ... \"role\": \"authenticated\" }`) and sets local role to it's value using `SET LOCAL ROLE authenticated`. |\n| **dbConfigName** | `request.jwt.claims` | JWT data is written local config variable using `set_config('request.jwt.claims', '{ ... }', true)` |\n\n**IMPORTANT NOTES:**\n\nYou should add a validated JWT to the context previously. JWT is not validated by this module. Storing a non-validated JWT in the context is unsecure.\n\n\u003c!-- Badges --\u003e\n[npm-version-src]: https://img.shields.io/npm/v/nuxt-prisma/latest.svg?style=flat\u0026colorA=18181B\u0026colorB=28CF8D\n[npm-version-href]: https://npmjs.com/package/nuxt-prisma\n\n[npm-downloads-src]: https://img.shields.io/npm/dm/nuxt-prisma.svg?style=flat\u0026colorA=18181B\u0026colorB=28CF8D\n[npm-downloads-href]: https://npmjs.com/package/nuxt-prisma\n\n[license-src]: https://img.shields.io/npm/l/nuxt-prisma.svg?style=flat\u0026colorA=18181B\u0026colorB=28CF8D\n[license-href]: https://npmjs.com/package/nuxt-prisma\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fozum%2Fnuxt-prisma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fozum%2Fnuxt-prisma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fozum%2Fnuxt-prisma/lists"}