@fernando.mema/sv-prisma
v0.1.1
Published
<a id="readme-top"></a>
Maintainers
Readme
View Prisma Docs · Report Bug · Request Feature
About
This addon sets up Prisma in your SvelteKit project with:
- Prisma schema with configurable database dialect
- Prisma client singleton with dev hot-reload support
- Database scripts (generate, push, migrate, studio)
- Environment variable configuration
- Optional driver adapter support (PostgreSQL, MySQL, LibSQL)
Installation
npx sv add @fernandomema/sv-prismaOptions
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| dialect | select | postgresql | Database dialect: PostgreSQL, MySQL, or SQLite |
| adapter | select | none | Driver adapter: none, pg, mysql, or libsql |
| output | string | src/lib/generated/prisma | Prisma client output path |
Adapter Options
| Adapter | Use Case |
|---------|----------|
| None | Standard Prisma client (recommended for most cases) |
| @prisma/adapter-pg | PostgreSQL driver adapter for connection pooling (Neon, SeaweedFS) |
| @prisma/adapter-mysql | MySQL driver adapter |
| @prisma/adapter-libsql | LibSQL/Turso driver adapter |
What It Does
Files Created
| File | Purpose |
|------|---------|
| prisma/schema.prisma | Prisma schema with generator and datasource |
| prisma.config.ts | Prisma 7 configuration file |
| src/lib/server/db.ts | Prisma client singleton with global caching |
Files Modified
| File | Changes |
|------|---------|
| .env | Adds DATABASE_URL |
| .env.example | Adds DATABASE_URL template |
| package.json | Adds scripts: db:generate, db:push, db:migrate, db:studio |
Scripts Added
| Script | Command | Description |
|--------|---------|-------------|
| db:generate | prisma generate | Generate Prisma client |
| db:push | prisma db push | Push schema to database |
| db:migrate | prisma migrate dev | Create and run migrations |
| db:studio | prisma studio | Open Prisma Studio GUI |
| build | prisma generate && vite build | Generate client before build |
Environment Variables
| Variable | Description | Example |
|----------|-------------|---------|
| DATABASE_URL | Database connection string | postgresql://user:pass@localhost:5432/mydb?schema=public |
Next Steps
After installation:
- Run
npx prisma generateto generate the Prisma client - Run
npm run db:pushto sync your schema to the database - Check
DATABASE_URLin.envand adjust it to your needs - Add your models to
prisma/schema.prisma
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE.txt for more information.
Contact
Fernando - @fernandomema
Project Link: https://github.com/fernandomema/sv-addons
Acknowledgments
- Prisma - Database ORM
- Svelte CLI - Official Svelte tooling
- Best README Template - README template
