It depends on what kind of place you personally define as "safe" and how far you want to commute. NOTHING is inexpensive in the Bay Area, but there are plenty of places where you can get help finding rentals, including possibly some really nice shared rental situations. When I lived there, I lived in the East Bay--Berkeley, Oakland, El Cerrito, and Albany. All have very nice areas and some not so nice sections. The more towards the hills you go, the nicer the neighborhoods, but also the more expensive. San Francisco tends to be the same way, but again, you could find something very nice in a mixed neighborhood that is perfectly safe, but not like some suburb.
Marin County, north of the city, is totally beautiful, but tends to be pretty outrageously expensive, but then I've heard of people who luck into a very cheap rental just because some wealthy person wants to leave the country for a year or two and needs someone reliable to house sit, so keep your eyes open.
The further south you go, either on the San Francisco side of the Bay or the East Bay side, the less expensive, more suburban, and longer the commute. There are some really nice areas just on the other side of the Oakland/Berkeley hills, and it's not a terrible commute.
Good luck and enjoy the Bay Area! I loved living there.