-
|
Hello Everyone
I want that once a user has started the upload, they should run in background and user should be able to come back to "/" and browse his listings or can initiate another listing. And all this time upload is going happen in the background. As I am first time trying NextJS, I am not able to figure out how and where put the background uploads. So that they can be shared between various pages and can run in the background and user can still browse the application. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
in my opinion this might be a little tricky because nextjs just like react will unmount the component/page as soon as you navigate away from it, i suppose i would maybe have the upload logic in someplace like the navbar or sidebar that would not be unmounted as i change routes (assuming i am using a layout that brings in pages as children) hence i could trigger a prop to start file upload on maybe the sidebar or navbar and trigger another prop or a global context whenever the upload is done just my idea. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for you reply. |
Beta Was this translation helpful? Give feedback.
-
|
Background uploads can definitely make the UX nicer, but I’d still treat the upload boundary as a trust boundary. Even if the upload happens asynchronously, I’d still run a server-side inspection step before the file is considered accepted, stored permanently, or made available elsewhere. I built an OSS package for this in Node.js: It fits well when you want background uploads without turning “upload completed” into “upload trusted”. |
Beta Was this translation helpful? Give feedback.
Thanks for you reply.
If I keep the code in _app.js, will all the subpages share the memory of it?
And the context passed from _app.js, will it be destroyed and re-created on page change?
I just want to keep something in memory for all the page and navigation.