use client on some parts of server-side component/page?
Answered
Chum salmon posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Chum salmonOP
If I have the following code and I only want part of it to be client-side (where the event handlers are), is that possible to do without breaking it out into a new, very specific component?
Thanks
Thanks
![Image](https://cdn.discordapp.com/attachments/1204682179163193384/1204682179448152115/image.png?ex=65d59eb5&is=65c329b5&hm=3e37fa8d9d34db8f05d08f33fff6be10e9fb3f1f2c78a560ff599337ce588598&)
24 Replies
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Chum salmonOP
I would only want this part, besides the H2 to be client side
![Image](https://cdn.discordapp.com/attachments/1204682179163193384/1204682388924276777/image.png?ex=65d59ee7&is=65c329e7&hm=ccdf7c8df5443fb0830a941c75531d8aeb115cdc48843fbaaf38bba7bdf333c9&)
![Avatar](https://cdn.discordapp.com/avatars/678259999201427466/1936f7e8963ff0f800f5eb4b43bc833c.webp?size=256)
Clown
Why arent you marking those two components are "use client" then?
You could also try dynamic importing "i think"
With ssr disabled(if needed)
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Chum salmonOP
They are, but I want to be able to compose the event bus which has to be done outside of the component
Plus, the button needs to be client-side too
dynamic importing?
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Chum salmonOP
Yes, this looks like what I need. Thank you
![Avatar](https://cdn.discordapp.com/avatars/678259999201427466/1936f7e8963ff0f800f5eb4b43bc833c.webp?size=256)
Clown
Try and come back here if it isnt what you need
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Chum salmonOP
Sounds good. Thank you
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Chum salmonOP
Actually, I thought you could append custom HTML to a
dynamic
call. I think lazy loading is assuming I already have a component in place?Do you just have to make a lot of components even if you only use them once? 🤔
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Chum salmonOP
The main drawback here is I'm trying to use client API's like button callbacks to dispatch event calls in this case. Like I'm trying to create an event bus which invokes all functions to send their data to an S3 bucket, but because I'm trying to do it this way it's forcing me to use a client component. I wonder if there's a way to do this without pulling it into a client component.
![Avatar](https://cdn.discordapp.com/avatars/678259999201427466/1936f7e8963ff0f800f5eb4b43bc833c.webp?size=256)
Clown
Did you try using the ssr option in dynamic()?
Also you need to pass a component while the component is loading using the loading prop inside dynamic()
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Chum salmonOP
I don't think that would solve my issue. The issue I'm having is I'm trying to compose how my components work together without creating a whole new component to do that
Is there a way to make a client component from a const function so I don't have to make a whole new file for it?
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Chum salmonOP
![Image](https://cdn.discordapp.com/attachments/1204682179163193384/1204875176026570822/image.png?ex=65d65273&is=65c3dd73&hm=8ff5b47d5b3c5b99e60fbe04ca7b1a97dc446524642fdab215bf4cc248f2a4ab&)
Yeah like this isn't working which is what I thought. I think dynamic is expecting an import
not JSX
otherwise I could just put my JSX into that and make it only client-side
![Image](https://cdn.discordapp.com/attachments/1204682179163193384/1204875308894003280/image.png?ex=65d65293&is=65c3dd93&hm=1699bf8a5889471ef59727b4a5c09fed9e888856654ade36f91ceee6b3c6462b&)
Because I get this