Dear student ,
in real manner H is a non metal but due to its valency 1 it may be placed with alkali metals and halogens both and when it combines with a strong alkakali metals like sodium it acts as a halogen and tend to accept electron from the metal and formed a negatively charged hydride ion.
Regards