Next JS: Warn User for Unsaved Form before Route Change

It seems there is no perfect way to this but I handle it with this little trick: React.useEffect(() => { const confirmationMessage=”Changes you made may not be saved.”; const beforeUnloadHandler = (e: BeforeUnloadEvent) => { (e || window.event).returnValue = confirmationMessage; return confirmationMessage; // Gecko + Webkit, Safari, Chrome etc. }; const beforeRouteHandler = (url: string) … Read more

Create upload files api in next.js

You can upload files with Next.js API routes. Example with default Next.js body parse API handler export default (req, res) => { // req.body contains a content of an uploaded file + headers } req.body is a string that contains related HTTP headers in the beginning like ——WebKitFormBoundarydj2uhBXPZtD3nte3 Content-Disposition: form-data; name=”your_input_name”; filename=”your_file_name.json” Content-Type: application/json your … Read more

NEXTJS: getServerSideProps not working into components

You cannot use getServerSideProps in non-page components. You can either pass the prop from Home to HomeSection or create a context so the value can be available globally from the component tree getServerSideProps can only be exported from a page. You can’t export it from non-page files. https://nextjs.org/docs/basic-features/data-fetching#only-allowed-in-a-page-2

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)