How works the wifi router?

How does the router work? Should I just buy it and it? Do I need an internet connection to get my wifi with the router? Does it work on batteries or something?