Use SvelteKit with 4Mica by running the Node adapter behind an Express server. Mount the 4Mica middleware before the SvelteKit handler for paid API routes.
This integration is not stable yet. For now, use the
NodeJS quick start for the supported implementation.
Use the private key only for buyer-side signing. Use PAY_TO as the seller
address advertised by protected routes.
Deposit collateral
Deposit collateral for the buyer wallet before making paid requests. Match the network in the client scheme and the protected route.To learn more about collateral setup, see Deposits and Withdrawals.
Protect a route
After building SvelteKit with the Node adapter, create an Express server entry that mounts paid routes first and then passes everything else to SvelteKit.
import express from "express";import { handler } from "./build/handler.js";import { paymentMiddlewareFromConfig } from "@4mica/x402/server/express";const server = express();server.use(express.json());server.use( paymentMiddlewareFromConfig( { "GET /api/premium-content": { accepts: { scheme: "4mica-credit", price: "$0.10", network: "eip155:84532", payTo: process.env.PAY_TO ?? "0xYourAddress", }, description: "Access to premium SvelteKit content", }, }, ),);server.get("/api/premium-content", (req, res) => { res.json({ message: "Paid content from SvelteKit" });});server.use(handler);server.listen(3000);
Support payment
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";import { FourMicaEvmScheme } from "@4mica/x402/client";import { privateKeyToAccount } from "viem/accounts";const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);const scheme = await FourMicaEvmScheme.create(account);export const fetchWithPayment = wrapFetchWithPaymentFromConfig(fetch, { schemes: [{ network: "eip155:84532", client: scheme }],});
Use it from server-only SvelteKit code:
const response = await fetchWithPayment("http://localhost:3000/api/premium-content");const data = await response.json();
⌘I
{"docsConfig":{"theme":"almond","$schema":"https://mintlify.com/docs.json","name":"4Mica docs","description":"The clearinghouse for the agentic economy","colors":{"primary":"#000","light":"#ffffff","dark":"#151515"},"logo":{"light":"https://mintcdn.com/4mica/4VGsKlanVlMSAASY/logo/light.svg?fit=max\u0026auto=format\u0026n=4VGsKlanVlMSAASY\u0026q=85\u0026s=01d19b38fe17d0867023f55e5105f367","dark":"https://mintcdn.com/4mica/4VGsKlanVlMSAASY/logo/dark.svg?fit=max\u0026auto=format\u0026n=4VGsKlanVlMSAASY\u0026q=85\u0026s=390d1a858284d091cf13864c8723c14b"},"favicon":{"light":"https://mintcdn.com/4mica/4VGsKlanVlMSAASY/logo/light.svg?fit=max\u0026auto=format\u0026n=4VGsKlanVlMSAASY\u0026q=85\u0026s=01d19b38fe17d0867023f55e5105f367","dark":"https://mintcdn.com/4mica/4VGsKlanVlMSAASY/logo/dark.svg?fit=max\u0026auto=format\u0026n=4VGsKlanVlMSAASY\u0026q=85\u0026s=390d1a858284d091cf13864c8723c14b"},"navbar":{"links":[{"href":"mailto:support@4mica.io","label":"Support"},{"href":"mailto:feedback@4mica.io","label":"Feedback"}],"primary":{"type":"button","label":"Launch App","href":"https://app.4mica.io"}},"footer":{"socials":{"x":"https://x.com/0x4Mica","github":"https://github.com/4Mica-Network","linkedin":"https://linkedin.com/company/4mica"}},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"styling":{"latex":false},"navigation":{"global":{"anchors":[{"anchor":"Website","icon":"globe","href":"https://4mica.io"},{"anchor":"GitHub","icon":"github","href":"https://github.com/4Mica-Network"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"4mica","hasAudioNarration":false,"actualSubdomain":"4mica","customDomains":["docs.4mica.io"],"gitSource":{"type":"github","owner":"4mica-network","repo":"4mica","deployBranch":"main","contentDirectory":"docs","isPrivate":false,"mountPath":"","label":""},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6afeaea6de236bae61681269","clientVersion":"0.0.4304","searchFilterCounts":[{"language":"default","tag":"Core Concepts","count":17},{"language":"default","tag":"Buyer","count":12},{"language":"default","tag":"Seller","count":12},{"language":"default","tag":"API Reference","count":11},{"language":"default","tag":"Quick Start","count":11},{"language":"default","tag":"Webhooks","count":9},{"language":"default","tag":"NodeJS","count":8},{"language":"default","tag":"Operator","count":6},{"language":"default","tag":"Getting Started","count":6},{"language":"default","tag":"SDKs","count":6}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[],"googleFontsInlined":true},"customCss":[]}
{"page":{"pagePath":"quick-start/sveltekit","slug":"/quick-start/sveltekit","pageMetadata":{"title":"SvelteKit","description":"Use 4Mica with SvelteKit on Node.","href":"/quick-start/sveltekit"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Use 4Mica with SvelteKit on Node.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,CodeGroup,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Use SvelteKit with 4Mica by running the Node adapter behind an Express server. Mount the 4Mica middleware before the SvelteKit handler for paid API routes.`}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`This integration is not stable yet. For now, use the\n`,_jsx(_components.a,{href:`/quick-start/nodejs`,children:`NodeJS quick start`}),` for the supported implementation.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`prerequisites`,children:`Prerequisites`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`SvelteKit configured with `,_jsx(_components.code,{children:`@sveltejs/adapter-node`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`A seller wallet address for `,_jsx(_components.code,{children:`payTo`}),`.`]}),`\n`,_jsx(_components.li,{children:`A buyer wallet with deposited 4Mica collateral.`}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`install`,children:`Install`}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`npm`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @sveltejs/adapter-node`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` express`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @4mica/x402`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @x402/fetch`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` viem`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`pnpm`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`pnpm`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @sveltejs/adapter-node`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` express`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @4mica/x402`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @x402/fetch`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` viem`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`yarn`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`yarn`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` add`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @sveltejs/adapter-node`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` express`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @4mica/x402`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @x402/fetch`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` viem`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`bun`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`bun`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` add`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @sveltejs/adapter-node`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` express`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @4mica/x402`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @x402/fetch`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` viem`})]}),`\n`]})})})]}),`\n`,_jsx(Heading,{level:`2`,id:`create-wallet`,children:`Create wallet`}),`\n`,_jsxs(_components.p,{children:[`For wallet setup, see `,_jsx(_components.a,{href:`/core-concepts/wallet`,children:`Wallet`}),`.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`PRIVATE_KEY`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`0xYourPrivateKey`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`PAY_TO`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`0xYourSellerAddress`})]}),`\n`]})})}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Use the private key only for buyer-side signing. Use `,_jsx(_components.code,{children:`PAY_TO`}),` as the seller\naddress advertised by protected routes.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`deposit-collateral`,children:`Deposit collateral`}),`\n`,_jsx(_components.p,{children:`Deposit collateral for the buyer wallet before making paid requests. Match the network in the client scheme and the protected route.`}),`\n`,_jsxs(_components.p,{children:[`To learn more about collateral setup, see `,_jsx(_components.a,{href:`/core-concepts/deposits-and-withdrawals`,children:`Deposits and Withdrawals`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`protect-a-route`,children:`Protect a route`}),`\n`,_jsx(_components.p,{children:`After building SvelteKit with the Node adapter, create an Express server entry that mounts paid routes first and then passes everything else to SvelteKit.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`30`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`30`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` express`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"express\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`handler`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"./build/handler.js\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`paymentMiddlewareFromConfig`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@4mica/x402/server/express\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` server`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` express`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`server`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`use`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`express`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`json`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`());`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`server`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`use`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` paymentMiddlewareFromConfig`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"GET /api/premium-content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` accepts:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` scheme:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"4mica-credit\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` price:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"$0.10\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` network:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"eip155:84532\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` payTo:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` process`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`env`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`PAY_TO`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ??`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"0xYourAddress\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` description:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Access to premium SvelteKit content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ),`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`server`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`get`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"/api/premium-content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`req`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`res`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` res`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`json`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`message:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Paid content from SvelteKit\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`server`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`use`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`handler`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`server`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`listen`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`3000`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`support-payment`,children:`Support payment`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`10`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`wrapFetchWithPaymentFromConfig`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@x402/fetch\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`FourMicaEvmScheme`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@4mica/x402/client\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`privateKeyToAccount`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"viem/accounts\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` account`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` privateKeyToAccount`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`process`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`env`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`PRIVATE_KEY`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` as`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `0x\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` scheme`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` FourMicaEvmScheme`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`create`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`account`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` fetchWithPayment`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` wrapFetchWithPaymentFromConfig`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` schemes:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [{ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`network:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"eip155:84532\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`client:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` scheme`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }],`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Use it from server-only SvelteKit code:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` response`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` fetchWithPayment`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"http://localhost:3000/api/premium-content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` data`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` response`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`json`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"SvelteKit","description":"Use 4Mica with SvelteKit on Node.","href":"/quick-start/sveltekit"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Prerequisites","slug":"prerequisites","depth":2,"children":[]},{"title":"Install","slug":"install","depth":2,"children":[]},{"title":"Create wallet","slug":"create-wallet","depth":2,"children":[]},{"title":"Deposit collateral","slug":"deposit-collateral","depth":2,"children":[]},{"title":"Protect a route","slug":"protect-a-route","depth":2,"children":[]},{"title":"Support payment","slug":"support-payment","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"4mica","siteName":"4Mica docs","title":"SvelteKit - 4Mica docs","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-06-30T15:04:59.365Z","originalFileLocation":"quick-start/sveltekit.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Use 4Mica with SvelteKit on Node.\">\u003cmeta data-mint-head name=\"application-name\" content=\"4Mica docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/4mica/UemErz3_BMHQ_An2/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/4mica/UemErz3_BMHQ_An2/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/4mica/UemErz3_BMHQ_An2/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/4mica/UemErz3_BMHQ_An2/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/4mica/UemErz3_BMHQ_An2/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/4mica/UemErz3_BMHQ_An2/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/4mica/UemErz3_BMHQ_An2/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/4mica/UemErz3_BMHQ_An2/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/4mica/UemErz3_BMHQ_An2/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"SvelteKit - 4Mica docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Use 4Mica with SvelteKit on Node.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"4Mica docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.4mica.io/quick-start/sveltekit\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://4mica.mintlify.site/_mintlify/api/og/v2?division=NodeJS\u0026amp;title=SvelteKit\u0026amp;description=Use+4Mica+with+SvelteKit+on+Node.\u0026amp;theme=9a2aab3377834dd43899dcf8\u0026amp;signature=7a2391cdafaa4f2f950d4b26928f77fbd84ab55e6dc6dda4a6ff86114612162e\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"SvelteKit - 4Mica docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Use 4Mica with SvelteKit on Node.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://4mica.mintlify.site/_mintlify/api/og/v2?division=NodeJS\u0026amp;title=SvelteKit\u0026amp;description=Use+4Mica+with+SvelteKit+on+Node.\u0026amp;theme=9a2aab3377834dd43899dcf8\u0026amp;signature=7a2391cdafaa4f2f950d4b26928f77fbd84ab55e6dc6dda4a6ff86114612162e\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/4mica/UemErz3_BMHQ_An2/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"4Mica docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#000\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.4mica.io/quick-start/sveltekit\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/quick-start/sveltekit.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.4mica.io/#organization\",\"name\":\"4Mica docs\",\"url\":\"https://docs.4mica.io\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/4mica/4VGsKlanVlMSAASY/logo/light.svg?fit=max\u0026auto=format\u0026n=4VGsKlanVlMSAASY\u0026q=85\u0026s=01d19b38fe17d0867023f55e5105f367\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.4mica.io#website\",\"name\":\"4Mica docs\",\"url\":\"https://docs.4mica.io\",\"publisher\":{\"@id\":\"https://docs.4mica.io/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.4mica.io/quick-start/sveltekit#webpage\",\"url\":\"https://docs.4mica.io/quick-start/sveltekit\",\"name\":\"SvelteKit\",\"description\":\"Use 4Mica with SvelteKit on Node.\",\"dateModified\":\"2026-06-30T15:04:59.365Z\",\"isPartOf\":{\"@id\":\"https://docs.4mica.io#website\"},\"breadcrumb\":{\"@id\":\"https://docs.4mica.io/quick-start/sveltekit#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.4mica.io/quick-start/sveltekit#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Quick Start\",\"item\":\"https://docs.4mica.io/quick-start/nodejs\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"NodeJS\",\"item\":\"https://docs.4mica.io/quick-start/nodejs\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"SvelteKit\",\"item\":\"https://docs.4mica.io/quick-start/sveltekit\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.4mica.io/quick-start/sveltekit#article\",\"headline\":\"SvelteKit\",\"name\":\"SvelteKit\",\"description\":\"Use 4Mica with SvelteKit on Node.\",\"url\":\"https://docs.4mica.io/quick-start/sveltekit\",\"mainEntityOfPage\":{\"@id\":\"https://docs.4mica.io/quick-start/sveltekit#webpage\"},\"dateModified\":\"2026-06-30T15:04:59.365Z\",\"publisher\":{\"@id\":\"https://docs.4mica.io/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.4mica.io#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"4Mica docs\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"4Mica docs\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/quick-start/sveltekit.md","siteName":"4Mica docs","nav":{"global":{"anchors":[{"anchor":"Website","icon":"globe","href":"https://4mica.io"},{"anchor":"GitHub","icon":"github","href":"https://github.com/4Mica-Network"}]},"pages":[{"group":"Getting Started","pages":[{"title":"4Mica Developer Docs","sidebarTitle":"Introduction","href":"/getting-started/introduction"},{"title":"Quickstart","href":"/getting-started/quickstart"},{"title":"All products","href":"/getting-started/all-products"},{"title":"Why we exist","href":"/getting-started/why-we-exist"},{"title":"Use cases","href":"/getting-started/usecases"},{"title":"Supported networks","href":"/getting-started/supported-networks"}]},{"group":"Quick Start","pages":[{"group":"NodeJS","pages":[{"title":"Introduction","href":"/quick-start/nodejs"},{"title":"NextJS","href":"/quick-start/nextjs"},{"title":"Express","href":"/quick-start/express"},{"title":"Hono","href":"/quick-start/hono"},{"title":"Nuxt","description":"Use 4Mica with a Nuxt app and a Node API route.","href":"/quick-start/nuxt"},{"title":"SvelteKit","href":"/quick-start/sveltekit"},{"title":"Remix","description":"Use 4Mica with a Remix Express server.","href":"/quick-start/remix"},{"title":"Bun","href":"/quick-start/bun"}]},{"group":"Python","pages":[{"title":"FastAPI","href":"/quick-start/fastapi"},{"title":"Flask","href":"/quick-start/flask"}]},{"title":"Rust","href":"/quick-start/rust"}]},{"group":"Background","pages":[{"title":"Agentic economy","href":"/background/agentic-economy"},{"title":"Agentic payments","href":"/background/agentic-payments"},{"title":"Agent identity","href":"/background/agent-identity"}]},{"group":"Core Concepts","pages":[{"title":"Getting started with core concepts","sidebarTitle":"Getting started","href":"/core-concepts/getting-started"},{"title":"How x402 works","href":"/core-concepts/how-x402-works"},{"title":"Transaction lifecycle","href":"/core-concepts/transaction-lifecycle"},{"title":"Deposits and withdrawals","href":"/core-concepts/deposits-and-withdrawals"},{"title":"Wallet","href":"/core-concepts/wallet"},{"title":"No custodial risk","href":"/core-concepts/no-custodial-risk"},{"title":"No account setup","href":"/core-concepts/no-account-setup"},{"title":"Collateral ratios","href":"/core-concepts/collateral-ratios"},{"title":"Bilateral netting cycles","href":"/core-concepts/bilateral-netting-cycles"},{"title":"Settlements","href":"/core-concepts/settlements"},{"title":"Micropayments at scale","href":"/core-concepts/micro-payments-at-scale"},{"title":"Security","href":"/core-concepts/security"},{"title":"Risk management","href":"/core-concepts/risk-management"},{"title":"Configurable SLAs","href":"/core-concepts/configurable-slas"},{"title":"Facilitator","href":"/core-concepts/facilitator"},{"title":"Earning yield","href":"/core-concepts/earning-yield"},{"title":"Cross-chain credit","href":"/core-concepts/cross-chain-credit"}]},{"group":"Buyer","pages":[{"title":"Quick Start","href":"/buyer/quick-start"},{"title":"Trust and Verification","href":"/buyer/trust-and-verification"},{"title":"Budgets and Spending Limits","href":"/buyer/budgets-and-spending-limits"},{"title":"Quality and Outcomes","href":"/buyer/quality-and-outcomes"},{"title":"Safety and Permissions","href":"/buyer/safety-and-permissions"},{"title":"Payment Proof and Audit","href":"/buyer/payment-proof-and-audit"},{"title":"Facilitator URLs","href":"/buyer/facilitator-urls"},{"title":"Make Paid Requests Automatically","href":"/buyer/make-paid-requests-automatically"},{"title":"Error Handling","href":"/buyer/error-handling"},{"title":"Test in Sandbox","href":"/buyer/test-in-sandbox"},{"title":"Go Live","href":"/buyer/go-live"},{"title":"FAQs","href":"/buyer/faqs"}]},{"group":"Seller","pages":[{"title":"Quick Start","href":"/seller/quick-start"},{"title":"Trust and Legitimacy","href":"/seller/trust-and-legitimacy"},{"title":"Pricing and Monetization","href":"/seller/pricing-and-monetization"},{"title":"Microtransactions","href":"/seller/microtransactions"},{"title":"Agent-to-Agent Payments","href":"/seller/agent-to-agent-payments"},{"title":"Proof and Disputes","href":"/seller/proof-and-disputes"},{"title":"Risk and Abuse Prevention","href":"/seller/risk-and-abuse-prevention"},{"title":"Facilitator URLs","href":"/seller/facilitator-urls"},{"title":"Payment Middleware","href":"/seller/payment-middleware"},{"title":"Test in Sandbox","href":"/seller/test-in-sandbox"},{"title":"Go Live","href":"/seller/go-live"},{"title":"FAQs","href":"/seller/faqs"}]},{"group":"SDKs","pages":[{"title":"Backend","href":"/sdks/backend"},{"group":"TypeScript SDK","pages":[{"title":"TypeScript SDK","href":"/sdks/typescript/overview"},{"title":"Configuration","href":"/sdks/typescript/configuration"},{"title":"Client operations","href":"/sdks/typescript/client-operations"},{"title":"X402 flow","href":"/sdks/typescript/x402-flow"},{"title":"Error handling","href":"/sdks/typescript/errors"}]}]},{"group":"Webhooks","pages":[{"title":"Overview","href":"/webhooks/overview"},{"title":"Quick Start","href":"/webhooks/quick-start"},{"group":"Events","pages":[{"title":"Collateral deposited","href":"/webhooks/events/collateral-deposited"},{"title":"Guarantee settled","href":"/webhooks/events/guarantee-settled"},{"title":"Withdrawal requested","href":"/webhooks/events/withdrawal-requested"},{"title":"Withdrawal finalized","href":"/webhooks/events/withdrawal-finalized"}]},{"title":"Security","href":"/webhooks/security"},{"title":"Best Practices","href":"/webhooks/best-practices"},{"title":"FAQs","href":"/webhooks/faqs"}]},{"group":"API Reference","pages":[{"group":"Facilitator","pages":[{"title":"Health check","href":"/api-reference/facilitator/health"},{"title":"List supported payment kinds","href":"/api-reference/facilitator/supported"},{"title":"Verify a payment","href":"/api-reference/facilitator/verify"},{"title":"Settle a payment","href":"/api-reference/facilitator/settle"}]},{"group":"Operator","pages":[{"title":"Create SIWE nonce","href":"/api-reference/operator/create-nonce"},{"title":"Verify SIWE signature","href":"/api-reference/operator/verify-siwe"},{"title":"Core health","href":"/api-reference/operator/health"},{"title":"Get public parameters","href":"/api-reference/operator/public-params"},{"title":"List supported tokens","href":"/api-reference/operator/tokens"},{"title":"Issue a guarantee","href":"/api-reference/operator/issue-guarantee"}]},{"title":"Payment Flow","href":"/api-reference/payment-flow"}]},{"title":"Changelogs","href":"/updates/changelogs"},{"title":"FAQs","href":"/support/faqs"}]},"basePath":"","title":"SvelteKit - 4Mica docs","deploymentId":"dpl_57NA6NKtrcUBhuxv6Tm2hAi21TK4","buildId":"dpl_57NA6NKtrcUBhuxv6Tm2hAi21TK4","dynamics":[],"chunks":[]}