@wix/runtime-fetch-adapter
v1.0.6
Published
Wix Runtime Fetch Adapter
Readme
Wix Runtime Fetch Adapter
A platform-agnostic Astro adapter that bundles applications as completely self-contained modules with a standard fetch interface.
Features
- ✅ Platform Agnostic: Works in any JavaScript runtime environment
- ✅ Self-Contained: Bundles all dependencies into a single module
- ✅ Standard Interface: Exposes
fetch(request, env)handler - ✅ Zero Dependencies: Final bundle requires no external dependencies at runtime
- ✅ Environment Variables: Pass environment variables via the
envparameter
Installation
npm install wix-runtime-fetch-adapterUsage
// astro.config.mjs
import { defineConfig } from 'astro/config';
import wixRuntimeFetchAdapter from 'wix-runtime-fetch-adapter';
export default defineConfig({
output: 'server',
adapter: wixRuntimeFetchAdapter()
});Runtime Usage
After building your Astro project, you can import and use the bundled module:
// Import the bundled module
const module = await import('./dist/server/entry.mjs');
const fetchHandler = module.default.fetch;
// Call the fetch handler
const env = { API_KEY: 'your-api-key' };
const request = new Request('http://localhost:3000/');
const response = await fetchHandler(request, env);Portability & Privacy
- The adapter removes build-machine specific paths from the SSR manifest for portable, leak-free bundles.
- Route metadata and built module specifiers remain intact to preserve runtime behavior.
License
MIT
