To add something to the socket, it would look something like assign(socket, :test, "test"). The absence of a socket param in the render callback indicates it’s not a good place to be updating the socket. I’d suggest taking a look at the overall LiveComponent lifecycle, and especially the mount or update callbacks instead.
Check out the Pitfalls section of the Assigns and HEEx templates guide. It explains why the render function isn’t the place to be defining variables and assigning things.
do not define variables at the top of your render function:
def render(assigns) do
sum = assigns.x + assigns.y
<%= sum %>
Instead explicitly precompute the assign in your LiveView, outside of render: