To register a widget in WordPress using a hook, you can use the widgets_init hook. Here’s an example code snippet that demonstrates how to register a custom widget:

add_action( 'widgets_init', 'my_register_sidebar' );

function my_register_sidebar(){
 register_sidebar(array(
 'name' => 'My new sidebar',
 'id' => 'your-sidebar-id',
 'description' => 'My sidebar description',
 'before_widget' => '<aside id="%1$s" class="widget group %2$s">',
 'after_widget' => '</aside>',
 'before_title' => '<h3 class="widget-title">',
 'after_title' => '</h3>',
 ));
}