You will need to go through US Immigration and Customs at Miami, regardless if you're only in the US for a few hours or a few months. If you're not eligible to enter the US, you will be refused entry and sent back to wherever you flew in from. If you do need a visa and don't have one, the airline at your departure airport won't even let you on the plane.