
Security News
arXiv Is Rate Limiting Authors Following a Flood of AI Slop Submissions
arXiv now limits authors to two submissions a month as AI slop overwhelms moderators, delays good papers, and sparks debate over applying the limit to everyone.
@edgestore/server
Advanced tools
Check the official documentation for more information.
Let's start by installing the required packages.
npm install @edgestore/server @edgestore/react
Then go to your Dashboard, create a new project and copy the keys to your environment variables.
EDGE_STORE_ACCESS_KEY=your-access-key
EDGE_STORE_SECRET_KEY=your-secret-key
Now we can create the backend code for our Next.js app.
EdgeStore is compatible with both types of Next.js apps (pages router and app router).
The example below is the simplest bucket you can create with EdgeStore. Just a simple file bucket with no validation that will be accessible by anyone with the link.
You can have multiple buckets in your app, each with its own configuration.
import { initEdgeStore } from '@edgestore/server';
import { createEdgeStoreNextHandler } from '@edgestore/server/adapters/next/app';
const es = initEdgeStore.create();
/**
* This is the main router for the EdgeStore buckets.
*/
const router = es.router({
publicFiles: es.fileBucket(),
});
const handler = createEdgeStoreNextHandler({
router,
});
export { handler as GET, handler as POST };
/**
* This type is used to create the type-safe client for the frontend.
*/
export type EdgeStoreRouter = typeof router;
Now let's initiate our context provider.
'use client';
import { createEdgeStoreProvider } from '@edgestore/react';
import { type EdgeStoreRouter } from '../app/api/edgestore/[...edgestore]/route';
const { EdgeStoreProvider, useEdgeStore } =
createEdgeStoreProvider<EdgeStoreRouter>();
export { EdgeStoreProvider, useEdgeStore };
And then wrap our app with the provider.
import { EdgeStoreProvider } from '../lib/edgestore';
import './globals.css';
// ...
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body>
<EdgeStoreProvider>{children}</EdgeStoreProvider>
</body>
</html>
);
}
You can use the useEdgeStore hook to access a typesafe frontend client and use it to upload files.
import * as React from 'react';
import { useEdgeStore } from '../lib/edgestore';
export default function Page() {
const [file, setFile] = React.useState<File>();
const { edgestore } = useEdgeStore();
return (
<div>
<input
type="file"
onChange={(e) => {
setFile(e.target.files?.[0]);
}}
/>
<button
onClick={async () => {
if (file) {
const res = await edgestore.publicFiles.upload({
file,
onProgressChange: (progress) => {
// you can use this to show a progress bar
console.log(progress);
},
});
// you can run some server action or api here
// to add the necessary data to your database
console.log(res);
}
}}
>
Upload
</button>
</div>
);
}
By passing the replaceTargetUrl option, you can replace an existing file with a new one.
It will automatically delete the old file after the upload is complete.
You can also upload the file using the same file name, but in that case, you might still see the old file for a while because of the CDN cache.
const res = await edgestore.publicFiles.upload({
file,
options: {
replaceTargetUrl: oldFileUrl,
},
// ...
});
await edgestore.publicFiles.delete({
url: urlToDelete,
});
FAQs
Upload files with ease from React/Next.js
The npm package @edgestore/server receives a total of 1,345 weekly downloads. As such, @edgestore/server popularity was classified as popular.
We found that @edgestore/server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
arXiv now limits authors to two submissions a month as AI slop overwhelms moderators, delays good papers, and sparks debate over applying the limit to everyone.

Research
/Security News
A new GhostAction wave hits hundreds of GitHub repos, expanding CI/CD secret theft to cloud and AI credentials in source code and git history.

Research
/Security News
Tensorlake npm SDK version 0.5.144 was compromised in a ChainDrop / Shai-Hulud attack, delivering credential-stealing malware.