The ferry from Dakar is the only way onto the island. Boats depart from the port terminal near Place de l'Indépendance, and the crossing takes around 20 minutes. Ferries run throughout the day, roughly every hour, with around ten departures daily.
Avoid the midday crossing if you can — the heat on the island is brutal between about 11am and 3pm, and the boats tend to be more crowded. Early morning or late afternoon is far more pleasant.
The return ferry runs until early evening; don't cut it too fine if you're planning to be back in Dakar for dinner.