Meteor is a full-stack JavaScript platform that is used for developing modern web and mobile applications. Meteor has a set of features that are helpful in creating a responsive and reactive web or mobile application using JavaScript or different packages available in the framework. It is used to build connected-client reactive applications.
You can use Meteor.isClient to limit the code to only run on the client-side and Meteor.isServer to limit the code to only run on the server-side. Anything outside of .isClient and .isServer is gonna run on both.
Syntax:
if (Meteor.isClient) {
// The code is now running on the client...
}
if (Meteor.isServer) {
// The code is now running on the server....
}
Â
Creating Meteor Application and Importing Module:
Step 1: Create a Meteor application using the following command.
meteor create foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command.
cd foldername
Step 3: Import Meteor module from ‘meteor/meteor’
import { Meteor } from 'meteor/meteor'
Project Structure: It will look like the following.
Step to Run Application: Run the application from the root directory of the project using the following command.
meteor
Example: It is the basic example that shows how to use the Core API component.
Main.html
<head>     <title>gfg</title> </head>   <body>     <h1 class="heading">neveropen</h1>       {{> hello}}     <!-- {{> info}} --></body>   <template name="hello">     <p>       You can use Meteor.isClient to limit       the code to only run on the client-side       and Meteor.isServer to limit the code to       only run on the server-side.     </p> </template> |
Main.js
import { Template } from 'meteor/templating'; import './main.html'; Â Â Template.hello.onCreated(function helloOnCreated() { Â Â Â Â if (Meteor.isClient) { Â Â Â Â Â Â Â Â // The code is now running on the client... Â Â Â Â Â Â Â Â console.log("Meteor is running in the client?, ", Â Â Â Â Â Â Â Â Â Â Â Â Meteor.isClient); Â Â Â Â Â Â Â Â console.log("Meteor is running in the server?, ", Â Â Â Â Â Â Â Â Â Â Â Â Meteor.isServer); Â Â Â Â } Â Â Â Â Â Â if (Meteor.isServer) { Â Â Â Â Â Â Â Â // The code is now running on the server.... Â Â Â Â Â Â Â Â console.log("Meteor is running in the client?, ", Â Â Â Â Â Â Â Â Â Â Â Â Meteor.isClient); Â Â Â Â Â Â Â Â console.log("Meteor is running in the server?, ", Â Â Â Â Â Â Â Â Â Â Â Â Meteor.isServer); Â Â Â Â } }); |
Output:
Reference: https://docs.meteor.com/api/core.html

