Villefranche-sur-Mer is about 6 km east of Nice and is on the train line between Nice and Monaco.
[Train at Villefranche-sur-Mer]
For much of the way from Nice to Monaco the train runs along the coast, with views of the Mediterranean and the mansions that cling to the cliffs along the way.
If you plan your day in advance you can take the local (regional) train which stops at all these little towns, as opposed the the InterCity trains, which only stop at larger cities. So with a train ticket from Nice to Monaco, you can stop off at any point along the way on the same ticket.
[Citadel Wall - Villefranche-sur-Mer]
Villefranche-sur-Mer is a popular spot for cruiseship day trippers. The Rolling Stones also found it agreeable, and recorded Exile on Main St. in a villa here.