Best way to save custom css for an block

I’m building a custom plugin and would like to store some user generated css for this block. Using add_action( 'wp_head', array( $ this, 'render_server_side_css' ) );, I get my css to the frontend (head), no problem. But is this js + php approach the best way or is there a more "gutenberg ready" approach to solve this issue?

And if that is the right way, how to generate some ids for styling? The client id is always changing, so that is not really an option …