8 min read
Building Type-Safe APIs with Nuxt 3 and Prisma
Learn how to build end-to-end type-safe APIs using Nuxt 3 server routes and Prisma ORM for a seamless developer experience.
1.9K
Deploy your Nuxt 3 app to the edge with Cloudflare Workers — zero cold starts, global distribution, and generous free tier.
Mbeah Essilfie
June 13, 2026 at 06:03 AM
# In your Nuxt project
pnpm add -D wrangler
Configure the preset:
// nuxt.config.ts
export default defineNuxtConfig({
nitro: {
preset: 'cloudflare-pages',
},
})
Create a wrangler config:
# wrangler.toml
name = "my-nuxt-app"
compatibility_date = "2024-01-01"
pages_build_output_dir = ".output/public"
[vars]
NUXT_PUBLIC_SITE_URL = "https://myapp.pages.dev"
# Build for Cloudflare
pnpm build
# Preview locally (uses miniflare)
pnpm wrangler pages dev .output/public
# Deploy
pnpm wrangler pages deploy .output/public
# Set secrets (never committed to code)
wrangler pages secret put DATABASE_URL
wrangler pages secret put AUTH_SECRET
Access them in server routes:
export default defineEventHandler((event) => {
const { DATABASE_URL } = event.context.cloudflare.env
// or use process.env.DATABASE_URL (Nuxt handles mapping)
})
Cloudflare offers edge-native services:
# wrangler.toml
[[d1_databases]]
binding = "DB"
database_name = "my-db"
database_id = "xxx"
[[r2_buckets]]
binding = "STORAGE"
bucket_name = "uploads"
[[kv_namespaces]]
binding = "CACHE"
id = "xxx"
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
- run: pnpm install
- run: pnpm build
- uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
projectName: my-nuxt-app
directory: .output/public
Edge deployment is the future. With Nuxt and Cloudflare, you're already there.
Fullstack Software Developer
Learn how to build end-to-end type-safe APIs using Nuxt 3 server routes and Prisma ORM for a seamless developer experience.
Go beyond basic utility classes and learn how to build cohesive, maintainable design systems with Tailwind CSS.
Understand the power of Vue 3's Composition API through practical, real-world composable patterns that you can use today.
