How to implement auto reload on changes in Next.js?
Unanswered
Ocicat posted this in #help-forum
OcicatOP
Hi. This is a rather beginner question. I want to make development more convenient and have my project reloaded on component changes, just like in React. Some time ago at work I used some watcher from npm to execute next build commands, but I feel like there should be a better way. I've read about Fast Refresh in Next.js, but according to docs it should work automatically on 9.4 or newer. I don't see that happening even tho I have 13 or something. Thank you in advance.
7 Replies
@Ocicat Hi. This is a rather beginner question. I want to make development more convenient and have my project reloaded on component changes, just like in React. Some time ago at work I used some watcher from npm to execute next build commands, but I feel like there should be a better way. I've read about Fast Refresh in Next.js, but according to docs it should work automatically on 9.4 or newer. I don't see that happening even tho I have 13 or something. Thank you in advance.
this is weird , i am using Next 13 and it works just fine for me
OcicatOP
So what should happen is whenever I edit a component, regardless if its TypeScript or JavaScript, it should just reload changes?
then wait a bit and your page will be loaded automatically (not a full reload, that's why we call it hot reloading, and that's why it's cool)
OcicatOP
Yeah I see. Do all folders and files have to have lowercase name? And what about imports? Should syntax look like this?
instead of
import Box from '../Components/Box';instead of
import Box from '../Components/box';For context I use shadcn ui also
@Ocicat Yeah I see. Do all folders and files have to have lowercase name? And what about imports? Should syntax look like this?
import Box from '../Components/Box';
instead of
import Box from '../Components/box';
you are totally free, if you name the file
however, it's better to use same naming convention to make it easier for you
ping me when replying
Box.tsx then you must import it it path/to/Box, and if you name it box.tsx you must import it as path/to/boxhowever, it's better to use same naming convention to make it easier for you
ping me when replying