What matters first: Zanzibar is part of the United Republic of Tanzania, so visitors use the Tanzania visa system rather than applying for a separate Zanzibar visa. A valid Tanzania visa can cover a safari on the mainland and a beach stay on the islands. Zanzibar also operates a separate mandatory inbound travel-insurance requirement, which is not a visa and must be handled through the official insurance platform.
When your route begins on the mainland and continues by domestic flight to Zanzibar, you remain within the same country for immigration purposes. Keep your passport and visa approval available during travel because airlines and local authorities may ask to see them. The island insurance certificate should be saved separately from the visa grant notice so each document can be produced quickly when requested.