Create main.js

split into client and server.  This is the client part.