How to fetch dynamic data in Next Js from database (eg. mongo DB) using Next Js API routes
I am currently building a small ecommerce shop and I am fetching data from mongo Db database to display to the user, the problem I have is that I am not getting the latest data from the database after I run the build command which seems to statically build each product data with the current data contained in the database and any updates on the data in the database does not reflect to the frontend. Here is my code in details (my code folder structure is in src>app)
How to make the Server component whenever the URL parameters changes
Can someone enlighten me on this? is it possible to trigger a re-fetch of data whenever the url parameter changes? because I tried this and it won’t work, on context I’m using router.navigate instead of link and also doesn’t work. Below is the code for your reference.
NextJS: Error: Cannot find module from [dot]next folder even though the file exists
I have a simple next application where /admin route lists the records and /new route open the form and after submitting the records it again redirects to the /admin page.
Next JS app router importing static image problem
I’m currently using the app router in Next.JS. When importing images from the public server using the one below from a reusable component
If you refresh the page many times in next js, you get ChunkLoadError: Loading chunk. Help please
Sometimes you get ChunkLoadError: Loading chunk. Can only be repeated if you reload the page many times. If you reload the page again, everything works fine again. Locally there are no problems or errors
it is not possible to transfer a variable to another variable
const [img, setImg] = useState(“”); const handleInputChange = (event) => { console.log(“event”, event.target.files); setData({ …data, loading: true }); img = event.target.files[0]; const info = new FormData(); info.append(“file”, img); axios.post(“http://localhost:3001/uploadImage/”, info, { headers: { “content-type”: “application/x-www-form-urlencoded”, }, }); }; я пытался получить “img” из const, но он выдаёт ошибку, почему? next.js next.js13 New contributor Максим Солдаткин […]
SingletonRouter is Null using NextJS13 imported from “next/router”
Context I’m trying to cancel the routing change when the user leaves the page without saving changes. To achieve this in Next.js, I need to listen to routing changes and cancel them using a handler function as middleware to intercept the route change Like this: import { Router } from ‘next/router’ Router.events.on(‘routeChangeStart’, handleChange) in order […]
Best way to embed Nextjs app in another website
I have a Nextjs app using app-directory and server-side rendering, I have been asked to create a white-label version for third parties to host on their websites, the simplest way is to use Iframe but it does not work properly due to router issues, and redirects do not work. the database is already configured for multiple organizations but I am not sure how to let the app know which organization is requesting the data. the ideal solution I am looking for is to host Nextjs on Vercel or Netlify, embed it somehow in another website, and let the app detect the organization based on the hostname
How to throw 404 Not Found Error along with 404 status code in NextJS 13 App Router from page.jsx?
I’m using async fetch request in page.tsx component similar to the below code
can’t render data properly inside new head.js next.js 13
I’m working on a project using new Next.js 13 app Dir, I’m trying to render the data from CMS. I’m getting the data works but no data is displayed on social share cards except the title showing (no meta tags available?)