You will have to go through immigration, collect your bags, go through customs, drop your bags back off, and go back through security upon entrance to the US - at MIA.
At JFK you won't have to collect bags. If you opt to go over to T4 to the lounge there, you will have to go back through security when you get back to T8.