core 0.0.1
Install from the command line:
Learn more about npm packages
$ npm install @edgefirst-dev/core@0.0.1
Install via package.json:
"@edgefirst-dev/core": "0.0.1"
About this version
The core of the Edge-first Stack.
bun add @edgefirst-dev/core
In your vite.config.ts
import getLoadContext
from @edgefirst-dev/core/vite
and pass it to Remix's Cloudflare plugin.
import {
vitePlugin as remix,
cloudflareDevProxyVitePlugin as cloudflare,
} from "@remix-run/dev";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import { getLoadContext } from "@edgefirst-dev/core/vite";
export default defineConfig({
plugins: [
cloudflare({ getLoadContext }),
remix({
future: {
v3_fetcherPersist: true,
v3_relativeSplatPath: true,
v3_throwAbortReason: true,
},
}),
tsconfigPaths(),
],
});
Now you can import Edge namespace from @edgefirst-dev/core
and use it in any part of your Remix app.
import { Edge } from "@edgefirst-dev/core";
let { items, meta } = await Edge.kv().keys();
let { data, meta } = await Edge.kv().get("prefix:key");
await Edge.kv().set(
"prefix:key",
{ date: new Date() },
{ ttl: 3600, metadata: { key: "value" } }
);