Donnager
Donnager
CDCloudflare Developers
Created by Donnager on 1/26/2024 in #next-on-pages
using just `next dev` not that i know of
thank you for the help sir!
81 replies
CDCloudflare Developers
Created by Donnager on 1/26/2024 in #next-on-pages
using just `next dev` not that i know of
if you are going to access cloudflare bindings in local yes, also if you deploy its all edge i believe
81 replies
CDCloudflare Developers
Created by Donnager on 1/26/2024 in #next-on-pages
using just `next dev` not that i know of
wowwww okay, did not know the runtime was required in local, it all makes sense now!!
81 replies
CDCloudflare Developers
Created by Donnager on 1/26/2024 in #next-on-pages
using just `next dev` not that i know of
hmm super baffling, can't wait to see it!
81 replies
CDCloudflare Developers
Created by Donnager on 1/26/2024 in #next-on-pages
using just `next dev` not that i know of
thank you so much for responding! okay yeah, totally makes sense, so curiously in his original post he said process.env.TESTKV was undefined, but he set up
TESTKV: {
type: "kv",
id: "TESTKV",
},
TESTKV: {
type: "kv",
id: "TESTKV",
},
what would be a likely cause then? hmm i am baffled
81 replies
CDCloudflare Developers
Created by Donnager on 1/26/2024 in #next-on-pages
using just `next dev` not that i know of
oh okay yeah hmm, what version of next-on-pages are you on? i just reset the binding to a new ID and it worked out of box, so i dont think we need wrangler very sorry to lead you down wrong path
81 replies
CDCloudflare Developers
Created by Donnager on 1/26/2024 in #next-on-pages
using just `next dev` not that i know of
i hate to @Better James , because its not his job to be in the discords, but he would know all the answers here, he is on EU time i believe, but maybe he will see it lol
81 replies
CDCloudflare Developers
Created by Donnager on 1/26/2024 in #next-on-pages
using just `next dev` not that i know of
not sure on the first question im a donkey sir, i believe preview is a separate deployment like staging
81 replies
CDCloudflare Developers
Created by Donnager on 1/26/2024 in #next-on-pages
using just `next dev` not that i know of
i think you will need to set up dashboard when you deploy, but not necessary for local, i also think wrangler defaults to local, hmmm
81 replies
CDCloudflare Developers
Created by Donnager on 1/26/2024 in #next-on-pages
using just `next dev` not that i know of
next dev:
const { setupDevBindings } = require("@cloudflare/next-on-pages/next-dev");
setupDevBindings({
bindings: {
CLOUDFLARE_BUCKET: {
type: "r2",
bucketName: "bucket",
},
CLOUDFLARE_KV: {
type: "kv",
id: "CLOUDFLARE_KV",
},
...
const { setupDevBindings } = require("@cloudflare/next-on-pages/next-dev");
setupDevBindings({
bindings: {
CLOUDFLARE_BUCKET: {
type: "r2",
bucketName: "bucket",
},
CLOUDFLARE_KV: {
type: "kv",
id: "CLOUDFLARE_KV",
},
...
server component:
const kv = getKv();
const pageViews = (await kv.get("page_view")) ?? 0;
const formattedPageViews =
typeof pageViews === "number" ? pageViews : Number(pageViews);
const kv = getKv();
const pageViews = (await kv.get("page_view")) ?? 0;
const formattedPageViews =
typeof pageViews === "number" ? pageViews : Number(pageViews);
edit: getkv
export const getKv = () => {
return process.env.CLOUDFLARE_KV as unknown as KVNamespace;
}
export const getKv = () => {
return process.env.CLOUDFLARE_KV as unknown as KVNamespace;
}
it reads for me using this, hmm only difference i see is you did import instead of require, but not sure why that would impact anything
81 replies
CDCloudflare Developers
Created by Donnager on 1/26/2024 in #next-on-pages
using just `next dev` not that i know of
i installed wrangler locally then:
npm run wrangler kv:namespace create
npm run wrangler kv:namespace create
81 replies
CDCloudflare Developers
Created by alrightsure on 1/24/2024 in #next-on-pages
Anyone get D1 working with local
wow! sounds like a major DX win! totally makes sense and good to know, the toml is great from my n00b perspective cause i got majorly tripped up the first time, i think this will make things super smooth for anyone new coming in, can't wait for this to merge!!
9 replies