Package Exports
- @gomomento/sdk-web
- @gomomento/sdk-web/dist/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@gomomento/sdk-web) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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.
- Website: https://www.gomomento.com/
- Momento Documentation: https://docs.momentohq.com/
- Getting Started: https://docs.momentohq.com/getting-started
- JavaScript Web SDK Documentation: https://docs.momentohq.com/develop/sdks/web
- Discuss: Momento Discord
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
/* eslint-disable @typescript-eslint/no-unsafe-assignment,@typescript-eslint/ban-ts-comment */
import {CacheGet, CacheClient, Configurations, CredentialProvider} from '@gomomento/sdk-web';
// @ts-ignore
// This global is required in order to use the Web SDK outside of a browser
global.XMLHttpRequest = require('xhr2');
async function main() {
const cacheClient = new CacheClient({
configuration: Configurations.Laptop.v1(),
credentialProvider: CredentialProvider.fromEnvironmentVariable({
environmentVariableName: 'MOMENTO_AUTH_TOKEN',
}),
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!