From the course: Next.js: Creating and Hosting a Full-Stack Site

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Data loading basics in Next.js

Data loading basics in Next.js

- [Instructor] All right, so now that we've added MongoDB to our route handlers, it's time for us to take a look at how to bring the front and back-ends of our application together. So, currently, we have the front-end of our application, which is the pages, and a sort of back-end to our application, which is the route handlers we've created, which are in charge of loading and responding with certain types of data. Now, what we want here is for our pages to actually load their data from those route handlers, right, by sending requests to those route handlers, and the main way that this is done in Next.js is by using the fetch function. If you're not already familiar with the fetch function as you may be from working with JavaScript or regular React, we're going to be taking a look at it in the context of Next.js here, and it's pretty exciting because in Next.js, the fetch function is actually much more powerful than the regular browser fetch function, because it allows us to do both…

Contents