pocket-region
v0.11.0
Published
AWS services like S3, DynamoDB, and Lambda inside a browser tab or Node, reached with the ordinary AWS SDK
Maintainers
Readme
Pocket Region
Pocket Region runs AWS services like S3, DynamoDB, and Lambda inside a browser tab or your Node process, and you call them with the ordinary AWS SDK. Your SDK calls reach the emulator as function calls, without a socket, so there's no container to start and no server to reach. Lambda handlers, Node or Python, run in Web Workers or child processes.
Try the demo in your tab, or read the docs at pocket-region.dev/docs, where you can edit and run the examples.
import { clientConfig, createRegion } from 'pocket-region/node';
import { S3Client, CreateBucketCommand, PutObjectCommand } from '@aws-sdk/client-s3';
const region = await createRegion();
const s3 = new S3Client(clientConfig(region));
await s3.send(new CreateBucketCommand({ Bucket: 'photos' }));
await s3.send(new PutObjectCommand({ Bucket: 'photos', Key: 'cat.txt', Body: 'meow' }));
await region.stop();It needs WebAssembly JSPI: Node 24.20 or later, or a browser that supports it.
The AWS APIs come from MiniStack, a Python AWS emulator that runs here under Pyodide.
In Node, the region lives in your test process and keeps real state, so a test can put an object and read it back. It's ready in about half a second, and resetting it to empty takes about a millisecond for a typical test, so every test can start clean without booting a new one.
Features
- The browser and Node: the same region runs in a page, which loads the emulator from jsDelivr with no files to copy, or in a Node process.
- Examples in your docs: add a Run button to
code examples written for real AWS.
createRunnerruns them in the reader's tab without any Pocket Region setup in the example. - Services: CloudWatch Logs, DynamoDB, EventBridge, Kinesis, KMS, S3, Secrets Manager, SNS, SQS, and SSM Parameter Store behave as they do in MiniStack, with a runnable example for each. Others, such as RDS and ECS, answer as stubs with nothing running behind them, or are untested here.
- Lambda: Node and Python functions run from a zipped deployment package, in child processes or Web Workers, with event source mappings.
- Resets and saves: empty a region between tests, or save its state to a store and boot from it later.
- Clients:
requestHandlerfor AWS SDK clients, andservefor anything that needs an endpoint. - The
awsCLI:awsClirunsawscommands and returns their output, for an AWS console in your own page or for tests.
In a real app
Glass Garden runs on Pocket Region. It opens on a working project, a load balancer in front of an instance group, and you can drag S3, SQS, DynamoDB, and Lambda onto the canvas and watch requests move through real code. Pocket Region started there as its AWS region and was pulled out so the same region can run in a test or any other page.
