Where does client-side code run, and where does server-side code run?
Options
- Both run on the server, never in the browser
- Client-side runs in the browser; server-side on a server (Correct option)
- Client-side runs in the DB; server-side in the browser
- Both run in the billing system of a cloud provider
Answer
Client-side runs in the user's browser or app; server-side runs on a server, which receives requests and sends responses
Why
Client-side code is downloaded to the user's device and runs there: for example the JavaScript that opens a menu when you click.
Server-side code runs on a server you control. It receives requests, talks to the database, checks permissions, and builds the response.
Anything on the client can be seen and changed by the user, so important checks (security, prices) must be repeated on the server.
Remember
Client-side = in the user's browser. Server-side = on your server.