bayrem🪽
bayrem🪽
PPrisma
Created by bayrem🪽 on 8/8/2024 in #help-and-questions
Accelerate: I cannot put my MongoDB connection string
No description
21 replies
PPrisma
Created by bayrem🪽 on 5/6/2024 in #help-and-questions
How to setup Next js apps on Vercel using Prisma....
I've been fighting bugs for ages, Mye learning journey is stuck for months just because i couldn't find a way to deploy my next js app on vercel that uses Prisma and MongoDB, I really have a question How to deploy on vercel with my prisma powered next app? Can I use accelerate on vercel? here are my files and how I use them:
import prisma from "@/lib/db";
import React from "react";

const handleSubmit = async (formData: FormData) => {
"use server";
const source = formData.get("source");
try {
const submit = await prisma.test.create({
data: {
source: source as string,
},
});
} catch (error) {
console.log(error);
throw new Error("Something went wrong");
}
};

const Form = () => {
return (
<div>
<form action={handleSubmit}>
<input name="source" type="text" />
<button>Submit</button>
</form>
</div>
);
};

export default Form;
import prisma from "@/lib/db";
import React from "react";

const handleSubmit = async (formData: FormData) => {
"use server";
const source = formData.get("source");
try {
const submit = await prisma.test.create({
data: {
source: source as string,
},
});
} catch (error) {
console.log(error);
throw new Error("Something went wrong");
}
};

const Form = () => {
return (
<div>
<form action={handleSubmit}>
<input name="source" type="text" />
<button>Submit</button>
</form>
</div>
);
};

export default Form;
import { PrismaClient } from "@prisma/client";

const prismaClientSingleton = () => {
return new PrismaClient();
};

declare const globalThis: {
prismaGlobal: ReturnType<typeof prismaClientSingleton>;
} & typeof global;

const prisma = globalThis.prismaGlobal ?? prismaClientSingleton();

export default prisma;

if (process.env.NODE_ENV !== "production") globalThis.prismaGlobal = prisma;
import { PrismaClient } from "@prisma/client";

const prismaClientSingleton = () => {
return new PrismaClient();
};

declare const globalThis: {
prismaGlobal: ReturnType<typeof prismaClientSingleton>;
} & typeof global;

const prisma = globalThis.prismaGlobal ?? prismaClientSingleton();

export default prisma;

if (process.env.NODE_ENV !== "production") globalThis.prismaGlobal = prisma;
5 replies
PPrisma
Created by bayrem🪽 on 4/16/2024 in #help-and-questions
Deployment to vercel failing
No description
12 replies