That's a complicated question, but here's the short answer. You will have to be very careful and consult with a good realtor and attorney in order to complete your transaction successfully.
Very little beachfront property in Costa Rica is titled, only some properties that were registered before the law was approved. The Maritime Zone law came into effect in 1979 and makes the first 50 meters from the high tide line public property. The next 150 meters can be given in concession and the concessions are managed by the city government. They are for 5-20 years and renewable.
If you meet all the requirements and make the purchase properly your concession is very secure. If you have been a legal resident of Costa Rica for 5 years, you may purchase a concession. Otherwise you have to form a company and over 50% of the capital must be Costa Rican. Here are is a good overview of real estate in Costa Rica.
Costa Rica Law