0.0.0-alpha.8 • Published 10 months ago
@edge-store/react v0.0.0-alpha.8
Getting Started
Next.js Setup
Install
npm install @edge-store/react
Environment Variables
# .env
EDGE_STORE_ACCESS_KEY=your-access-key
EDGE_STORE_SECRET_KEY=your-secret-key
API Route
// pages/api/edgestore/[...edgestore].js
import EdgeStore from "@edge-store/react/next";
export default EdgeStore();
Provider
// pages/_app.jsx
import { EdgeStoreProvider } from "@edge-store/react";
export default function App({ Component, pageProps }) {
return (
<EdgeStoreProvider>
<Component {...pageProps} />
</EdgeStoreProvider>
);
}
Upload image
import { useEdgeStore } from "@edge-store/react";
const Page = () => {
const [file, setFile] = useState(null);
const { upload } = useEdgeStore();
return (
<div>
<input type="file" onChange={(e) => setFile(e.target.files[0])} />
<button
onClick={async () => {
await upload({
file,
key: "path/to/image.jpg",
});
}}
>
Upload
</button>
</div>
);
};
export default Page;
Show image
import { useEdgeStore } from "@edge-store/react";
const Page = () => {
const { getImgSrc } = useEdgeStore();
return (
<div>
<img src={getImgSrc("path/to/image.jpg")} />
</div>
);
};
0.0.0-alpha.9
10 months ago
0.0.0-alpha-.0
10 months ago
0.0.0-alpha.11
10 months ago
0.0.0-alpha.10
10 months ago
0.0.0-alpha.0
1 year ago
0.0.0-beta.5
1 year ago
0.0.0-alpha.3
1 year ago
0.0.0-alpha.4
1 year ago
0.0.0-alpha.1
1 year ago
0.0.0-alpha.2
1 year ago
0.0.0-alpha.7
1 year ago
0.0.0-alpha.8
1 year ago
0.0.0-alpha.5
1 year ago
0.0.0-alpha.6
1 year ago
0.0.0-beta.4
1 year ago
0.0.0-beta.3
1 year ago
0.0.0-beta.2
1 year ago
0.0.0-beta.1
1 year ago
0.0.0-beta.0
1 year ago