deco-server-functions-invoke

Route Deco server actions through a build-time generated invoke bridge to solve VTEX CORS issues.

5|2|Updated Feb 26, 2026
One-click install
npx skills add https://github.com/decocms/deco-start --skill deco-server-functions-invoke
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: deco-server-functions-invoke
Source: https://github.com/decocms/deco-start/tree/main/.cursor/skills/deco-server-functions-invoke
Command: npx skills add https://github.com/decocms/deco-start --skill deco-server-functions-invoke

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The Deco server functions invoke workflow addresses a browser CORS problem by routing actions through a build-time generated server bridge, ensuring server-side execution and credentials stay hidden from the client.

Core Features & Use Cases

  • Three-layer architecture: pure functions in @decocms/apps, a generator in @decocms/start, and a generated site bridge (invoke.gen.ts) in the site.
  • Build-time code generation for top-level server functions, producing RPC-ready stubs that the TanStack Start runtime can transform.
  • Use cases include debugging CORS in cart/checkout, adding new server actions, and wiring invoke for a new Deco site.

Quick Start

Run the generate-invoke.ts script to produce the invoke.gen.ts bridge and then import ~/server/invoke.gen to use invoke.vtex.actions.* in your UI.

Frequently Asked Questions about deco-server-functions-invoke

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix CORS errors during VTEX cart and checkout in a Deco storefront?

To fix VTEX CORS errors in a Deco storefront, route server actions through a build-time generated invoke bridge. This shifts direct browser calls to server-side RPC execution over /_server, keeping credentials hidden and bypassing browser restrictions.

How does the Deco invoke bridge securely execute server functions?

The Deco invoke bridge executes server functions securely by using a build-time generator to emit top-level createServerFn handlers. The client calls generated RPC stubs over /_server, ensuring server-side execution and credentials stay hidden from the browser.

How do I add a new server action to a Deco site using the invoke workflow?

To add a new server action, run the generate-invoke.ts script in @decocms/start. This produces an invoke.gen.ts bridge and RPC-ready stubs, allowing you to import ~/server/invoke.gen and call invoke.vtex.actions.* directly in your UI.

Can I use TanStack Start runtime with Deco server functions for VTEX integration?

Yes, Deco server functions integrate with TanStack Start. The build-time generator produces top-level server functions and RPC-ready stubs that the TanStack Start runtime can transform for secure server-side execution over the /_server endpoint.

What is the architecture of the Deco server functions invoke workflow?

The Deco invoke workflow uses a three-layer architecture: pure functions in @decocms/apps, a build-time generator in @decocms/start, and a generated site bridge (invoke.gen.ts) within the site to route browser calls safely to the server.

Why are my direct browser calls failing with CORS in my Deco VTEX implementation?

Direct browser calls fail with CORS because VTEX restricts cross-origin requests. The Deco invoke workflow solves this by replacing direct calls with a generated invoke.gen.ts bridge, routing actions through server-side RPC stubs over /_server.