Answers for "image in next .js"

1

using next js image component

import Image from 'next/image';
export default function Home() {
   return (
       <div>
           <Image
               src='/assets/pexels-kendall-hoopes-6000x4000.jpg'
               alt='universe'
               width={1500}
               height={1000}
           />
       </div>
   )
}
Posted by: Guest on July-12-2021
0

how to add img in next.js

yarn add next-images

// add in next.config.js
const withImages = require('next-images')
module.exports = withImages()

//where the image should go
<img src={require('./my-image.jpg')} />
//or
import img from './my-image.jpg';
export default () => <div>
  <img src={img} />
</div>
Posted by: Guest on June-25-2020

Browse Popular Code Answers by Language