I use src
directory alongside of the app directory. so, the app
directory, is inside of the src
directory.
now, I created a folder inside of src
called hooks
, and this is my simple hook:
// useIsClient.js
import { useEffect, useState } from "react";
export default function useIsClient() {
const [isClient, setIsClient] = useState(false);
useEffect(() => {
setIsClient(true);
}, []);
return isClient;
}
as you can see there’s no use client
but if you import it inside of a client component, it will work.
I wonder if Nextjs detects the use
keyword so it knows, it is not a component and it is a hook, and this is why it works or everything inside of the app
directory is server-side component but not the whole src
.
which one of these assumptions is true?