Use import.meta.client. Specifying the mode.
<script setup> if(import.meta.client){ window... } </script>