Ordering Newest Messages First

Now we want to show our messages in ascending order. Without this step, they will end up displaying randomly.

Add a Timestamp to New Messages

With the JavaScript Date constructor, we can generate the current time in milliseconds. We then pass that into Firebase’s timestamp method as we save it to the database. Modify your message adding event Firebase query like this:

Get hands-on with 1200+ tech skills courses.