As most other answers suggest using long exposure times, I'd like to add that this is very dependent on the number and intensity of the fireworks themselves.
During bigger fireworks shows, long times like 4 seconds of exposure (even with a small aperture) would probably be too much and render too long trails.
Here is one example taken on New Year's Eve (2011) in Copacabana where 1.6 seconds and a not that small aperture (4.5 on a Canon Powershot) were enough for a decent exposure, including the people in front of the camera.
OTOH, there are times where you need more exposure time. On quieter moments of the show you may be able to use longer times in order to capture not only the fireworks but the also the (not much lit) foreground:
Here is what would be my checklist:
White balancing can be really trick, experiment with it before the fireworks begin if possible.
Turn off image stabilization.
Focus on infinity and use the lowest ISO possible.
The camera needs to be really stable (not necessarily using a tripod). Look for plane surfaces like tables or chairs, but a rock or trunk will do if you manage to align the camera correctly. Watch out for passing people and their interference.
If you don't have a remote shutter release (as most compacts don't), use the camera timer (2 seconds are enough) in order to not shake the camera after pressing the shutter. This will make timing shots a lot harder, but still viable (see below).
Try to take some shots before things start and the check background/foreground exposure, white balance and composition. It can be hard to setup things during the show and you may end up loosing a lot of shots during the process.
After you've found one (or two at most) position that looks good, wait for the first few fireworks in order to estimate the time it takes from the launching sound (usually lower in intensity) to the blasting itself. This will give you a rough idea of when to press the shutter if you are using the camera timer.
Once you feel the timing of the fireworks, fire at will. Just keep checking the results and adjusting the shutter time in order to get your desired trail length while keeping the exposure under control.
In the previous example, I started with a 4 seconds exposure and 8 aperture but found out that Rio's show was a lot brighter than expected and the fireworks were much faster too, so I had to quickly adapt and reduce the shutter speed while opening the aperture.
Concerning the location of the camera, even when using a tripod try to find a non crowded place (a harder than expected task since people are generally good at find the good places to stay). Since you will be using longer exposures, the camera will stay really vulnerable to vibration or to people jumping around. Depending on how close you are to the fireworks, even the sound of them can be enough to make the camera vibrate more than you would like.
One thing that I learned the hard way is that 28mm is not that wide when you are close to the fireworks launching pads. You maybe forced to choose (under quite a stress) between showing the fireworks completely or the foreground.
Here is an example of a 28mm lens being able to handle the composition of the fireworks and the foreground (note how blurred things are due to rain, people and wind):
But on this other example, where the fireworks were way closer, it was not possible to include the boats reflections, even while clipping part of the fireworks top curves:
Shooting fireworks is a continuos learning experience, too bad we don't have many chances to do this in Rio other than on December 31th. :o)