{"id":19683884,"url":"https://github.com/prisma/bridg-ea-quickstart","last_synced_at":"2025-06-20T07:33:30.983Z","repository":{"id":237633247,"uuid":"794927687","full_name":"prisma/bridg-ea-quickstart","owner":"prisma","description":"A quick-start template using Prisma Bridg.","archived":false,"fork":false,"pushed_at":"2024-05-05T09:09:22.000Z","size":138,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-13T11:15:43.590Z","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/prisma.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":"2024-05-02T08:37:54.000Z","updated_at":"2024-05-05T09:09:25.000Z","dependencies_parsed_at":"2024-05-05T10:24:10.130Z","dependency_job_id":null,"html_url":"https://github.com/prisma/bridg-ea-quickstart","commit_stats":null,"previous_names":["prisma/bridg-ea-quickstart"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/prisma/bridg-ea-quickstart","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fbridg-ea-quickstart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fbridg-ea-quickstart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fbridg-ea-quickstart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fbridg-ea-quickstart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prisma","download_url":"https://codeload.github.com/prisma/bridg-ea-quickstart/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fbridg-ea-quickstart/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260901195,"owners_count":23079723,"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-11-11T18:15:58.910Z","updated_at":"2025-06-20T07:33:25.973Z","avatar_url":"https://github.com/prisma.png","language":"TypeScript","readme":"# Prisma Bridg EA Quickstart\nA quick-start template using Prisma Bridg.\n\nThis project was bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) and [`prisma init`](https://www.prisma.io/docs/orm/reference/prisma-cli-reference#init)\n\n## Setup\n### 1. Clone repo\n```shell\ngit clone git@github.com:prisma/bridg-ea-quickstart.git\ncd bridg-ea-quickstart\n```\n\n### 2. Install dependencies\n```shell\nnpm install\n```\n\n### 4. Run\n```shell\nnpm run dev\n```\n\nYou should see an empty chat interface at `http://localhost:3000` \n\n## Getting setup on the Prisma Data Platform\n\nPrisma Bridg works seamlessly with [Prisma Accelerate](https://www.prisma.io/data-platform/accelerate) and [Prisma Pulse](https://www.prisma.io/data-platform/pulse). Let's enable them.\n\nNavigate to your Prisma Data Platform workspace and create a new project. Let's call it, **Prisma Bridg Chat**. This will create a default environment for your project.\n\nNext, we'll enable Accelerate and Pulse for this project.\n\n\u003eIf you need a database to complete this setup, you can use our [Railway DB template](https://railway.app/template/pulse-pg) to easily provision a Postgres database.\n\n### 5. Enable Accelerate\n- Provide your direct database connection string and select the region nearest your database to enable Accelerate. We'll skip static IP support for demo purposes.\n- Once enabled, you can generate your Accelerate API key. You'll note the API Key was generated in the format of a connection string, use this as your DATABASE_URL in your .env file.\n\n```shell\nDATABASE_URL=\"\"\n```\n\nWhen replacing your DATABASE_URL with your new Accelerate connection string, you can keep your direct database connection string as `DIRECT_DATABASE_URL` for migration support.\n\n### 6. Migrate Database\n- Requires `DIRECT_DATABASE_URL` to be set in your .env file\n\n```shell\nnpx prisma db push\n```\n\n### 7. Enable Pulse\n- Navigate to the Pulse tab within your project's production environment (where we just enabled Accelerate)\n- Provide your direct database connection string and select the region nearest your database to enable Pulse. We'll use the automatic setup.\n- Once enabled, you'll be able to Generate an API Key for Pulse. Add the generated API Key to your .env file\n\n```shell\nPULSE_API_KEY=\"\"\n```\n\nGreat! You've now enabled Prisma Accelerate and Prisma Pulse for your project. Let's add Prisma Bridg to our application\n\n### 8. Add Prisma Bridg\nFrom within your project directory, run the following command to add Prisma Bridg to your project.\n\n```shell\nnpx bridg-cli init\n```\n\nThis will do the following for you,\n1. Install remaining dependencies\n2. Generate the `bridg-server.ts` and `bridg.ts` files for you\n3. Deploy your managed Bridg endpoint\n\nYou're all set 🚀  Let's see how we can use Prisma Bridg to power our chat application.\n\n### Add Bridg to your application\nNavigate to `/src/app/page.tsx`and import Bridg at the top of the file.\n\n```tsx\nimport bridg from \"bridg\";\n```\n\nAdd the following code to the `useEffect` hook in the `Home` function.\n\n```tsx\nuseEffect(() =\u003e {\n  (async () =\u003e {\n    /**\n     * Bridg supports any authentication method you want to use.\n     * Simply add your authentication logic in bridg-server.ts.\n     */\n    await bridg.$socket.authenticate({ auth: \"some-token\" });\n\n    // Fetch any existing message from the database\n    await bridg.message.findMany().then((res) =\u003e setMessages(res));\n\n    // Let's create a new subscription to capture any new messages\n    // @ts-ignore\n    const subscription = await bridg.message.subscribe();\n    for await (const event of subscription) {\n      setEvents((prev) =\u003e [...prev, event]);\n    }\n  })();\n}, []);\n```\n\nReplace the `\u003cButton /\u003e` alert with the following code to send new messages.\n\n```tsx\n\u003cButton className=\"ml-2\" onClick={() =\u003e bridg.message.create({ data: { body: newMessage } })}\u003eSend\u003c/Button\u003e\n```\n\nIf you try to send a message now you'll get the following error message.\n\u003e Unauthorized Bridg query on model: message\n\nThis is becuase we have not yet refined our Bridg rules. Navigate to the `prisma/bridg.ts` file and modify the following code.\n\n```ts\nmessage: {\n  find: (uid) =\u003e true, // udpate this to true, so that we can fetch messages\n  update: (uid, data) =\u003e false,\n  create: (uid, data) =\u003e true, // udpate this to true, so that we can create new messages\n  delete: (uid) =\u003e false,\n},\n```\n\nDeploy your latest Bridg rules by running the following command.\n\n```shell\n  npx bridg-cli deploy\n```\n\nIf you create a new message now you should see it appear in the chat interface 💬\n\n# Feedback\nLet us know if you have any thoughts, questions, or feedback via Discord!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprisma%2Fbridg-ea-quickstart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprisma%2Fbridg-ea-quickstart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprisma%2Fbridg-ea-quickstart/lists"}