Salt flats are generally formed where ancient oceans, seas or even lakes have become cut off and water can only evaporate out of them. The Dead Sea is a current example, as is Great Salt Lake in Utah.
So sometime in the past, your river might have drained into a low lying area without access to the sea and the waters evaporated away, leaving the salt beds. At some more recent time in geological history, an earthquake or other geological change changed the course of the river, opening a channel to the sea.
Alternatively, the sea itself could have had an arm leading into the region which was cut off from the rest of the sea due to some geological event, eventually leaving great salt flats as the water evaporated away (which would be of greater extent and depth than those left by a more recent salt lake). The river's path could have moved closer to the salt flat over the ages, so its position today is a fortunate coincidence. A thousand years from now, the river could actually be running through the salt flat, washing the salt back into the sea.