\href{http://travis-ci.org/socketio/socket.io-client}{\texttt{ }} \href{https://david-dm.org/socketio/socket.io-client}{\texttt{ }} \href{https://david-dm.org/socketio/socket.io-client\#info=devDependencies}{\texttt{ }} \href{https://www.npmjs.com/package/socket.io-client}{\texttt{ }}  \href{http://slack.socket.io}{\texttt{ }}

\href{https://saucelabs.com/u/socket}{\texttt{ }}\hypertarget{md_sfcode_node_modules_socket_io_client_README_autotoc_md27820}{}\doxysection{How to use}\label{md_sfcode_node_modules_socket_io_client_README_autotoc_md27820}
A standalone build of {\ttfamily socket.\+io-\/client} is exposed automatically by the socket.\+io server as {\ttfamily /socket.io/socket.\+io.\+js}. Alternatively you can serve the file {\ttfamily socket.\+io.\+js} found in the {\ttfamily dist} folder or include it via \href{https://cdn.jsdelivr.net/npm/socket.io-client@2/dist/socket.io.js}{\texttt{ CDN}}.


\begin{DoxyCode}{0}
\DoxyCodeLine{<script src="{}/socket.io/socket.io.js"{}></script>}
\DoxyCodeLine{<script>}
\DoxyCodeLine{  var socket = io('http://localhost');}
\DoxyCodeLine{  socket.on('connect', function()\{\});}
\DoxyCodeLine{  socket.on('event', function(data)\{\});}
\DoxyCodeLine{  socket.on('disconnect', function()\{\});}
\DoxyCodeLine{</script> }

\end{DoxyCode}



\begin{DoxyCode}{0}
\DoxyCodeLine{// with ES6 import}
\DoxyCodeLine{import io from 'socket.io-\/client';}
\DoxyCodeLine{}
\DoxyCodeLine{const socket = io('http://localhost'); }

\end{DoxyCode}


A slim build (without {\ttfamily JSON3}, a JSON polyfill for IE6/\+IE7, and {\ttfamily debug}) is also available\+: {\ttfamily socket.\+io.\+slim.\+js}.

Socket.\+IO is compatible with \href{http://browserify.org/}{\texttt{ browserify}} and \href{https://webpack.js.org/}{\texttt{ webpack}} (see example \href{https://github.com/socketio/socket.io/tree/2.0.3/examples/webpack-build}{\texttt{ there}}).\hypertarget{md_sfcode_node_modules_socket_io_client_README_autotoc_md27821}{}\doxysubsection{Node.\+JS (server-\/side usage)}\label{md_sfcode_node_modules_socket_io_client_README_autotoc_md27821}
Add {\ttfamily socket.\+io-\/client} to your {\ttfamily package.\+json} and then\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{var socket = require('socket.io-\/client')('http://localhost');}
\DoxyCodeLine{socket.on('connect', function()\{\});}
\DoxyCodeLine{socket.on('event', function(data)\{\});}
\DoxyCodeLine{socket.on('disconnect', function()\{\});}

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_socket_io_client_README_autotoc_md27822}{}\doxysection{API}\label{md_sfcode_node_modules_socket_io_client_README_autotoc_md27822}
See API\hypertarget{md_sfcode_node_modules_socket_io_client_README_autotoc_md27823}{}\doxysection{License}\label{md_sfcode_node_modules_socket_io_client_README_autotoc_md27823}
\href{/LICENSE}{\texttt{ MIT}} 