Socket
Socket
Sign inDemoInstall

moralis

Package Overview
Dependencies
10
Maintainers
8
Versions
330
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    moralis

The Moralis JavaScript SDK


Version published
Weekly downloads
68K
decreased by-5.96%
Maintainers
8
Created
Weekly downloads
 

Readme

Source

Moralis Build Serverless web3 apps

Moralis SDK for JavaScript

A library that gives you access to the powerful Moralis Server backend from your JavaScript app. Create Server Here


For more information on Moralis and its features, see the website, the JavaScript guide, the Cloud Code guide or Web3 Reference.

Getting Started

The easiest way to integrate the Moralis SDK into your JavaScript project is through the npm module. However, if you want to use a pre-compiled file, you can fetch it from unpkg. The development version is available at https://unpkg.com/moralis/dist/moralis.js, and the minified production version is at https://unpkg.com/moralis/dist/moralis.min.js.

Webpack v5 support

There are a lot of breaking changes in Webpack v5. Set up your project to work with Moralis JS SDK:

configuring Webpack v5

We highly recommend you to use the stable 4.0.3 version of Webpack. If you want to use Moralis on your project with Webpack v5 you need to add the fallback to your webpack.config.js file:

module.exports = {
    resolve: {
        fallback: {
            assert: require.resolve('assert'),
            crypto: require.resolve('crypto-browserify'),
            http: require.resolve('stream-http'),
            https: require.resolve('https-browserify'),
            os: require.resolve('os-browserify/browser'),
            stream: require.resolve('stream-browserify'),
        },
    },
};

Using Moralis on Different Platforms

The JavaScript ecosystem is wide and incorporates a large number of platforms and execution environments. To handle this, the Moralis npm module contains special versions of the SDK tailored to use in Node.js and React Native environments. Not all features make sense in all environments, so using the appropriate package will ensure that items like local storage, user sessions, and HTTP requests use appropriate dependencies. For server side rendered applications, you may set the SERVER_RENDERING variable to prevent warnings at runtime.

To use the npm modules for a browser based application, include it as you normally would:

const Moralis = require('moralis');
// ES6 Minimized
import Moralis from 'moralis/dist/moralis.min.js';

For server-side applications or Node.js command line tools, include 'moralis/node':

// In a node.js environment
const Moralis = require('moralis/node');

For React Native applications, include 'moralis/react-native.js':

// In a React Native application
const Moralis = require('moralis/react-native.js');

// On React Native >= 0.50 and Moralis >= 1.11.0, set the Async
const AsyncStorage = require('react-native').AsyncStorage;
Moralis.setAsyncStorage(AsyncStorage);

Typescript support

Typescript types are supported out-of-the box. The types are defined in /types. These are updated with every release.

Keywords

FAQs

Last updated on 09 May 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc