Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chakra UI not loading Images locally

I am having some difficulties loading local images using Chakra UI with Next.js.

<Image src="./homepage/footer/Black.svg" />

This is the folder structure

1

In my console:

2

like image 551
Tek58 Avatar asked Oct 23 '25 03:10

Tek58


2 Answers

instead of directly referencing image path, try variable import like below ( i have imported my image as logo )

import { Box, Image, VStack } from '@chakra-ui/react';
import logo from './../../assets/images/xyz.png';

const Home = () => {
  return (
    <Box minH="100vh" className="hero-gradient">
      <VStack>
        <Image src={logo} alt="logo" />
      </VStack>
    </Box>
  );
};
export default Home;
like image 69
Prem G Avatar answered Oct 25 '25 18:10

Prem G


Try to put the public folder in the root at the same level as src folder.

https://nextjs.org/docs/basic-features/static-file-serving

like image 45
Douglas Henrique Avatar answered Oct 25 '25 16:10

Douglas Henrique



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!