Socket
Socket
Sign inDemoInstall

@gomomento/sdk-web

Package Overview
Dependencies
9
Maintainers
1
Versions
110
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @gomomento/sdk-web

Client SDK for Momento services


Version published
Weekly downloads
495
decreased by-9.17%
Maintainers
1
Install size
5.53 MB
Created
Weekly downloads
 

Readme

Source
logo

project status project stability

Momento JavaScript Web Client Library

Momento Cache is a fast, simple, pay-as-you-go caching solution without any of the operational overhead required by traditional caching solutions. This repo contains the source code for the Momento JavaScript Web client library.

To get started with Momento you will need a Momento Auth Token. You can get one from the Momento Console.

Packages

The JavaScript Web SDK is available on npmjs: @gomomento/sdk-web.

The web SDK is the best choice for client-side JavaScript applications, such as code that will run in a browser. For node.js server-side applications, check out the Momento Node.js SDK.

Usage

import {CacheGet, CacheClient, Configurations, CredentialProvider} from '@gomomento/sdk-web';
import {initJSDom} from './utils/jsdom';
async function main() {
  // Because the Momento Web SDK is intended for use in a browser, we use the JSDom library to set up an environment
  // that will allow us to use it in a node.js program.
  initJSDom();
  const cacheClient = new CacheClient({
    configuration: Configurations.Laptop.v1(),
    credentialProvider: CredentialProvider.fromEnvironmentVariable({
      environmentVariableName: 'MOMENTO_API_KEY',
    }),
    defaultTtlSeconds: 60,
  });

  await cacheClient.createCache('cache');
  await cacheClient.set('cache', 'foo', 'FOO');
  const getResponse = await cacheClient.get('cache', 'foo');
  if (getResponse instanceof CacheGet.Hit) {
    console.log(`Got value: ${getResponse.valueString()}`);
  }
}

main().catch(e => {
  throw e;
});

Getting Started and Documentation

Documentation is available on the Momento Docs website.

Examples

Working example projects, with all required build configuration files, are available in the examples subdirectory.

Developing

If you are interested in contributing to the SDK, please see the CONTRIBUTING docs.


For more info, visit our website at https://gomomento.com!

FAQs

Last updated on 14 May 2024

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