wedmaniacW
Denoβ€’3y agoβ€’
12 replies
wedmaniac

How can I make sure the code gets run on the client-side??!

import { useEffect, useState } from "preact/hooks";

export default function Callback() {
    useEffect(() => {
        const hashParam = window.location.hash.substring(1);
        console.log(`Param: ${hashParam}`);
       
    }, []);

    return (
        <div>
            ....
        </div>
    );
}


I would assume that the code is getting fired on the server side and that the error occurs when it is trying to access the window. Thank you in advance!
image.png
Was this page helpful?