<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Developer Guide on Emma Forms</title><link>https://xnok.github.io/emma/docs/developer-guide/</link><description>Recent content in Developer Guide on Emma Forms</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://xnok.github.io/emma/docs/developer-guide/index.xml" rel="self" type="application/rss+xml"/><item><title>Cloudflare Setup</title><link>https://xnok.github.io/emma/docs/developer-guide/cloudflare-setup/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://xnok.github.io/emma/docs/developer-guide/cloudflare-setup/</guid><description>&lt;p>To use Emma with Cloudflare, you need to set up the following services:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>R2:&lt;/strong> For storing form assets.&lt;/li>
&lt;li>&lt;strong>D1:&lt;/strong> For storing form submissions.&lt;/li>
&lt;li>&lt;strong>Workers:&lt;/strong> For running the API worker that processes form submissions.&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Note:&lt;/strong> The &lt;code>emma init&lt;/code> command will automatically handle the creation and configuration of these services for you. The following steps are provided for your reference and for manual setup if needed.&lt;/p>
&lt;h2 id="step-1-create-an-r2-bucket">Step 1: Create an R2 Bucket&lt;/h2>
&lt;ol>
&lt;li>Log in to your Cloudflare account and navigate to the &lt;strong>R2&lt;/strong> section.&lt;/li>
&lt;li>Click &lt;strong>Create bucket&lt;/strong> and give your bucket a name (e.g., &lt;code>emma-forms&lt;/code>).&lt;/li>
&lt;li>Take note of the &lt;strong>Bucket Name&lt;/strong> and your &lt;strong>Account ID&lt;/strong>.&lt;/li>
&lt;/ol>
&lt;h2 id="step-2-create-a-d1-database">Step 2: Create a D1 Database&lt;/h2>
&lt;ol>
&lt;li>Navigate to the &lt;strong>Workers &amp;amp; Pages&lt;/strong> section and click on &lt;strong>D1&lt;/strong>.&lt;/li>
&lt;li>Click &lt;strong>Create database&lt;/strong> and give your database a name (e.g., &lt;code>emma-submissions&lt;/code>).&lt;/li>
&lt;li>Take note of the &lt;strong>Database Name&lt;/strong> and &lt;strong>Database ID&lt;/strong>.&lt;/li>
&lt;/ol>
&lt;h2 id="step-3-create-a-worker">Step 3: Create a Worker&lt;/h2>
&lt;ol>
&lt;li>Navigate to the &lt;strong>Workers &amp;amp; Pages&lt;/strong> section and click on &lt;strong>Create application&lt;/strong>.&lt;/li>
&lt;li>Select &lt;strong>Create Worker&lt;/strong> and give your worker a name (e.g., &lt;code>emma-api-worker&lt;/code>).&lt;/li>
&lt;li>Click &lt;strong>Deploy&lt;/strong>.&lt;/li>
&lt;/ol>
&lt;h2 id="step-4-obtain-api-credentials">Step 4: Obtain API Credentials&lt;/h2>
&lt;ol>
&lt;li>Go to &lt;strong>My Profile&lt;/strong> &amp;gt; &lt;strong>API Tokens&lt;/strong>.&lt;/li>
&lt;li>Click &lt;strong>Create Token&lt;/strong> and select &lt;strong>Create Custom Token&lt;/strong>.&lt;/li>
&lt;li>Give your token a name (e.g., &lt;code>emma-cli-token&lt;/code>).&lt;/li>
&lt;li>Grant the following permissions:
&lt;ul>
&lt;li>&lt;strong>Account&lt;/strong> &amp;gt; &lt;strong>Workers R2 Storage&lt;/strong>: &lt;code>Edit&lt;/code>&lt;/li>
&lt;li>&lt;strong>Account&lt;/strong> &amp;gt; &lt;strong>Workers Scripts&lt;/strong>: &lt;code>Edit&lt;/code>&lt;/li>
&lt;li>&lt;strong>Account&lt;/strong> &amp;gt; &lt;strong>D1&lt;/strong>: &lt;code>Edit&lt;/code>&lt;/li>
&lt;li>&lt;strong>Zone&lt;/strong> &amp;gt; &lt;strong>Workers Routes&lt;/strong>: &lt;code>Edit&lt;/code> (if using a custom domain)&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>Click &lt;strong>Continue to summary&lt;/strong> and then &lt;strong>Create Token&lt;/strong>.&lt;/li>
&lt;li>Copy the generated token and store it in a secure location.&lt;/li>
&lt;/ol>
&lt;h2 id="step-5-get-r2-s3-api-credentials">Step 5: Get R2 S3 API Credentials&lt;/h2>
&lt;ol>
&lt;li>Navigate to the &lt;strong>R2&lt;/strong> section and click on your R2 bucket.&lt;/li>
&lt;li>Go to the &lt;strong>Settings&lt;/strong> tab.&lt;/li>
&lt;li>Under &lt;strong>R2.dev API&lt;/strong>, click &lt;strong>Connect to R2.dev&lt;/strong>.&lt;/li>
&lt;li>Click &lt;strong>Create API token&lt;/strong>.&lt;/li>
&lt;li>Copy the &lt;strong>Access Key ID&lt;/strong> and &lt;strong>Secret Access Key&lt;/strong>.&lt;/li>
&lt;/ol></description></item><item><title>CLI Configuration</title><link>https://xnok.github.io/emma/docs/developer-guide/cli-configuration/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://xnok.github.io/emma/docs/developer-guide/cli-configuration/</guid><description>&lt;p>Once you have set up your Cloudflare services and obtained the necessary credentials, you need to configure the &lt;code>emma-cli&lt;/code> to use them. Emma uses environment variables for all authentication, so no credentials are ever stored on your local machine.&lt;/p>
&lt;h2 id="required-environment-variables">Required Environment Variables&lt;/h2>
&lt;p>You need to set the following environment variables in your shell:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># For R2 access&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>export R2_ACCESS_KEY_ID&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;your-r2-access-key-id&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>export R2_SECRET_ACCESS_KEY&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;your-r2-secret-access-key&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>export R2_ACCOUNT_ID&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;your-cloudflare-account-id&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>export R2_BUCKET_NAME&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;your-r2-bucket-name&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>export R2_PUBLIC_URL&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;your-r2-public-url&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># For API worker deployment&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>export CLOUDFLARE_API_TOKEN&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;your-cloudflare-api-token&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>export CLOUDFLARE_ACCOUNT_ID&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;your-cloudflare-account-id&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>You can add these lines to your shell&amp;rsquo;s configuration file (e.g., &lt;code>~/.bashrc&lt;/code>, &lt;code>~/.zshrc&lt;/code>) to make them permanent.&lt;/p></description></item><item><title>Hugo Integration</title><link>https://xnok.github.io/emma/docs/developer-guide/hugo-integration/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://xnok.github.io/emma/docs/developer-guide/hugo-integration/</guid><description>&lt;p>Emma provides a Hugo shortcode to easily embed your forms into a Hugo website.&lt;/p>
&lt;h2 id="configure-your-hugo-site">Configure Your Hugo Site&lt;/h2>
&lt;p>In your Hugo site&amp;rsquo;s configuration file (&lt;code>config.toml&lt;/code> or &lt;code>hugo.toml&lt;/code>), add the following lines to the &lt;code>params&lt;/code> section:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-toml" data-lang="toml">&lt;span style="display:flex;">&lt;span>[&lt;span style="color:#a6e22e">params&lt;/span>]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">emmaCdnUrl&lt;/span> = &lt;span style="color:#e6db74">&amp;#34;your-r2-public-url&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Replace &lt;code>your-r2-public-url&lt;/code> with the public URL of your R2 bucket (or deployment provider URL).&lt;/p>
&lt;h2 id="basic-usage">Basic Usage&lt;/h2>
&lt;h3 id="simple-embed">Simple Embed&lt;/h3>
&lt;p>To embed a form, use the &lt;code>embed-form&lt;/code> shortcode in your Markdown content, passing the form ID as a parameter:&lt;/p></description></item><item><title>Authentication</title><link>https://xnok.github.io/emma/docs/developer-guide/authentication/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://xnok.github.io/emma/docs/developer-guide/authentication/</guid><description>&lt;p>Emma uses a token-based authentication strategy to securely interact with Cloudflare services. All authentication is handled through environment variables, ensuring that no sensitive credentials are ever stored on your local machine.&lt;/p>
&lt;h2 id="cloudflare-api-token">Cloudflare API Token&lt;/h2>
&lt;p>To deploy and manage the API worker, D1 database, and R2 bucket, you need a Cloudflare API token with the following permissions:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Account&lt;/strong> &amp;gt; &lt;strong>Workers R2 Storage&lt;/strong>: &lt;code>Edit&lt;/code>&lt;/li>
&lt;li>&lt;strong>Account&lt;/strong> &amp;gt; &lt;strong>Workers Scripts&lt;/strong>: &lt;code>Edit&lt;/code>&lt;/li>
&lt;li>&lt;strong>Account&lt;/strong> &amp;gt; &lt;strong>D1&lt;/strong>: &lt;code>Edit&lt;/code>&lt;/li>
&lt;li>&lt;strong>Zone&lt;/strong> &amp;gt; &lt;strong>Workers Routes&lt;/strong>: &lt;code>Edit&lt;/code> (if using a custom domain)&lt;/li>
&lt;/ul>
&lt;p>You can create this token in the Cloudflare dashboard under &lt;strong>My Profile&lt;/strong> &amp;gt; &lt;strong>API Tokens&lt;/strong>.&lt;/p></description></item><item><title>Form Schema Versioning</title><link>https://xnok.github.io/emma/docs/developer-guide/form-schema-versioning/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://xnok.github.io/emma/docs/developer-guide/form-schema-versioning/</guid><description>&lt;p>Emma uses a snapshot-based approach to versioning forms, which provides a simple yet powerful way to manage changes over time.&lt;/p>
&lt;h2 id="snapshots">Snapshots&lt;/h2>
&lt;p>Every time you edit a form, Emma creates a new, immutable snapshot of the form&amp;rsquo;s schema. Each snapshot is identified by a timestamp and is stored as a separate asset in your R2 bucket. This means that every version of your form is independently deployable.&lt;/p>
&lt;h2 id="viewing-form-history">Viewing Form History&lt;/h2>
&lt;p>You can view the history of a form, including all its snapshots, using the &lt;code>emma history&lt;/code> command:&lt;/p></description></item></channel></rss>