Middle
How closely have you worked with Next.js? What features do you use?
sobes.tech AI
Answer from AI
I have worked with Next.js on medium and large projects. I use the following features:
- SSR (Server-Side Rendering) for improved SEO and fast initial rendering.
- Static Generation (SSG) for pages with rarely changing content, which speeds up loading.
- API Routes to create backend endpoints directly within the project.
- Dynamic Routing for convenient creation of pages with parameters.
- Image Optimization with the
<Image>component for automatic image optimization. - Using getStaticProps and getServerSideProps for data loading at build time or request time.
Example of using getStaticProps:
export async function getStaticProps() {
const res = await fetch('https://api.example.com/data');
const data = await res.json();
return { props: { data } };
}
function Page({ data }) {
return <div>{data.title}</div>;
}
export default Page;