DEV Community

Discussion on: Adding an API and database to your Nuxt App with Prisma

Collapse
 
ruheni profile image
Ruheni Alex

Hey Manoj, 👋🏽

Prisma runs on the server-side. If you're using Nuxt, you can run Prisma in the asyncData and fetch hooks at either a page or component level.

I created a small demo you can check out experimenting how this would work. Your feedback on this would be appreciated too 🙂

Collapse
 
manojap profile image
MANOJ AP

I managed to create a middleware API in Nuxt
I also tried PrismaClient as Vue plugin(Vue.use) and it fails.
Same result in Vuex store.

gist.github.com/manojap/fb0d973551...

Thread Thread
 
manojap profile image
MANOJ AP
Thread Thread
 
ruheni profile image
Ruheni Alex

The sample on Codesandbox should work just fine. I've managed to query data – both the REST and GraphQL API.

Could you share the error you get when you use a Vue plugin?