惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Heimdal Security Blog
小众软件
小众软件
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
罗磊的独立博客
Google DeepMind News
Google DeepMind News
大猫的无限游戏
大猫的无限游戏
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
A
About on SuperTechFans
宝玉的分享
宝玉的分享
博客园 - 聂微东
月光博客
月光博客
Cyberwarzone
Cyberwarzone
Microsoft Security Blog
Microsoft Security Blog
V
Visual Studio Blog
Project Zero
Project Zero
T
Tor Project blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 最新话题
博客园 - 叶小钗
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Attack and Defense Labs
Attack and Defense Labs
Spread Privacy
Spread Privacy
Forbes - Security
Forbes - Security
Simon Willison's Weblog
Simon Willison's Weblog
N
Netflix TechBlog - Medium
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
Hacker News: Ask HN
Hacker News: Ask HN
I
InfoQ
M
MIT News - Artificial intelligence
AI
AI
博客园 - 三生石上(FineUI控件)
W
WeLiveSecurity
C
Check Point Blog
The Hacker News
The Hacker News
C
Cyber Attacks, Cyber Crime and Cyber Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Tenable Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
Blog — PlanetScale
Blog — PlanetScale
美团技术团队
D
Darknet – Hacking Tools, Hacker News & Cyber Security
GbyAI
GbyAI
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
K
Kaspersky official blog

Blog — PlanetScale

Keeping a Postgres queue healthy — PlanetScale Patterns for Postgres Traffic Control — PlanetScale Graceful degradation in Postgres — PlanetScale High memory usage in Postgres is good, actually — PlanetScale Stripe Projects partnership: Provision PlanetScale Postgres and MySQL databases from the Stripe CLI — PlanetScale Enhanced tagging in Postgres Query Insights — PlanetScale Behind the scenes: How Database Traffic Control works — PlanetScale Introducing Database Traffic Control — PlanetScale Scaling Postgres connections with PgBouncer — PlanetScale Drizzle joins PlanetScale — PlanetScale Video Conferencing with Postgres — PlanetScale Faster PlanetScale Postgres connections with Cloudflare Hyperdrive — PlanetScale Introducing the PlanetScale MCP server — PlanetScale Database Transactions — PlanetScale Automating our changelog with Cursor commands — PlanetScale Postgres 18 is now available — PlanetScale Using MotherDuck with PlanetScale — PlanetScale $50 PlanetScale Metal is GA for Postgres — PlanetScale AI-Powered Postgres index suggestions — PlanetScale $5 PlanetScale is live — PlanetScale Announcing Vitess 23 — PlanetScale $50 PlanetScale Metal — PlanetScale Report on our investigation of the 2025-10-20 incident in AWS us-east-1 — PlanetScale $5 PlanetScale — PlanetScale Benchmarking Postgres 17 vs 18 — PlanetScale Larger than RAM Vector Indexes for Relational Databases — PlanetScale Partnering with Cloudflare to bring you the fastest globally distributed applications — PlanetScale Processes and Threads — PlanetScale PlanetScale for Postgres is now GA — PlanetScale Postgres High Availability with CDC — PlanetScale Announcing Neki — PlanetScale Caching — PlanetScale The principles of extreme fault tolerance — PlanetScale Announcing PlanetScale for Postgres — PlanetScale Benchmarking Postgres — PlanetScale Announcing Vitess 22 — PlanetScale The Real Failure Rate of EBS — PlanetScale IO devices and latency — PlanetScale Announcing PlanetScale Metal — PlanetScale PlanetScale Metal: There’s no replacement for displacement — PlanetScale Upgrading Query Insights to Metal — PlanetScale Automating cherry-picks between OSS and private forks — PlanetScale Database Sharding — PlanetScale Anatomy of a Throttler, part 3 — PlanetScale Introducing sharding on PlanetScale with workflows — PlanetScale Announcing Vitess 21 — PlanetScale Announcing the PlanetScale vectors public beta — PlanetScale Anatomy of a Throttler, part 2 — PlanetScale Instant deploy requests — PlanetScale Anatomy of a Throttler, part 1 — PlanetScale Increase IOPS and throughput with sharding — PlanetScale Tracking index usage with Insights — PlanetScale Faster backups with sharding — PlanetScale Building data pipelines with Vitess — PlanetScale The State of Online Schema Migrations in MySQL — PlanetScale Optimizing aggregation in the Vitess query planner — PlanetScale Dealing with large tables — PlanetScale Announcing Vitess 20 — PlanetScale Self-managed Vitess vs Managed Vitess with PlanetScale — PlanetScale Achieving data consistency with the consistent lookup Vindex — PlanetScale The MySQL adaptive hash index — PlanetScale Introducing global replica credentials — PlanetScale Profiling memory usage in MySQL — PlanetScale Summer 2023: Fuzzing Vitess at PlanetScale — PlanetScale How PlanetScale makes schema changes — PlanetScale Identifying and profiling problematic MySQL queries — PlanetScale The Problem with Using a UUID Primary Key in MySQL — PlanetScale Announcing Vitess 19 — PlanetScale PlanetScale forever — PlanetScale Introducing schema recommendations — PlanetScale Amazon Aurora Pricing: The many surprising costs of running an Aurora database — PlanetScale Three common MySQL database design mistakes — PlanetScale OAuth applications are now available to everyone — PlanetScale Deprecating the Scaler plan — PlanetScale PlanetScale branching vs. Amazon Aurora blue/green deployments — PlanetScale Databases at scale — PlanetScale Considerations for building a database disaster recovery plan — PlanetScale Working with Geospatial Features in MySQL — PlanetScale PlanetScale vs Amazon Aurora replication — PlanetScale Introducing the Vantage and PlanetScale integration — PlanetScale MySQL isolation levels and how they work — PlanetScale Introducing the schemadiff command line tool — PlanetScale $ pscale ping — PlanetScale Announcing foreign key constraints support — PlanetScale The challenges of supporting foreign key constraints — PlanetScale What is HTAP? — PlanetScale Introducing Insights Anomalies — PlanetScale Webhook security: a hands-on guide — PlanetScale MySQL replication: Best practices and considerations — PlanetScale A guide to HTML email with Ruby on Rails and Tailwind CSS — PlanetScale Sharding for cost-effective database management — PlanetScale PlanetScale ranks 188th in Deloitte’s top 500 fastest-growing companies — PlanetScale Announcing the Fivetran integration — PlanetScale Introducing webhooks — PlanetScale What is MySQL replication and when should you use it? — PlanetScale Sync user data between Clerk and a PlanetScale MySQL database — PlanetScale Introducing database reports — PlanetScale Distributed caching systems and MySQL — PlanetScale What is MySQL partitioning? — PlanetScale MySQL High Availability: Connection handling and concurrency — PlanetScale
Personalizing your onboarding with Markdoc — PlanetScale
Ayrton · 2023-10-06 · via Blog — PlanetScale

Ayrton |

We recently released a new and improved onboarding flow for PlanetScale. The goal of our new onboarding is to help developers quickly connect and query their PlanetScale databases.

How to connect varies greatly by the language and framework your application uses. Each framework has small quirks, so it was important to us that no matter what language/framework your application uses, we offer a one-track path for you to get connected.

Onboarding page - create a new database Onboarding page - select a framework

The key to building out this onboarding was Markdoc. This post will go into more detail about how we built our product onboarding using Markdoc.

More flexibility with Markdoc

Markdoc, created by Stripe, is a Markdown-based syntax for creating custom documentation sites.

One of the reasons we're able to ship so quickly at PlanetScale is because we prioritize easy-to-use tools that allow anyone at the company to contribute. For this reason, using Markdown and GitHub for our product onboarding was an obvious choice for us.

As we started building, we quickly realized we wanted to have more interactive and personalized content. Static Markdown content just wasn't going to cut it. This is when we had the idea to explore using Markdoc.

The Markdoc syntax is a superset of Markdown, specifically the CommonMark specification. This means you can write content in the Markdown you know and love, but also allows you to extend it to add custom attributes, custom tags, and use functions and/or variables.

Building out the onboarding

Let's dive into some of the code. The following snippet is part of the Markdown used to render a connection tutorial in the onboarding flow.

```bash
rails credentials:edit --environment production
```

Add the following:

```bash {% file="config/credentials.yml.enc" %}
planetscale:
  username: {% $user %}
  host: {% $host %}
  database: {% $database %}
  password: {% $password %}
```

Onboarding page showing Rails-specific tutorial

You'll notice that we are using variables here inside the Markdown, i.e., $user, $host, $database, and $password. The goal was for each path in onboarding to be custom to the user and as easy as possible for them to follow. Providing easily copy and pastable code specific to the selected framework was key. And this is where variables became important.

Variables in Markdoc

Variables let you customize your Markdoc documents at runtime. We use variables to inline the users credentials directly into the content rather than using a static placeholder value.

This is a lot like blade templates in Laravel and erb templates in Ruby on Rails. The following snippet shows how we set up variables to populate those Markdown fields.

Note

All credentials have been invalidated prior to publishing this. We are leaving the full, unblurred credentials in for clarity.

import React from 'react'
import { parse, renderers, transform } from '@markdoc/markdoc'

export default function Page() {
  const config = {
    variables: {
      host: 'us-east.connect.psdb.cloud',
      user: 'mpl0y3jv3a92h4qc4ufn',
      database: 'beam',
      password: 'pscale_pw_V8db13jnq5mrOWcGFn6GTs6AerDI7A0womsmnJ1qxOc',
      ssl_ca: '/etc/ssl/certs/ca-certificates.crt'
    }
  }

  const doc = `# Configure your application\n…`
  const ast = parse(doc)
  const content = transform(ast, config)
  const children = renderers.react(content, React, {})

  return <div>{children}</div>
}

Nodes in Markdoc

To help contextualize the file that the onboarding code snippets live in, we want to extend the code blocks to accept an additional file attribute. Markdoc nodes enable you to customize how your document renders without using any custom syntax.

The following example extends the code snippet from the previous section by adding a new fence node, which displays the filename above a code snippet.

import React from 'react'
import { parse, renderers, transform } from '@markdoc/markdoc'

export default function Page() {
  const config = {
    nodes: {
      fence: Fence.scheme
    },
    variables: {
      host: 'us-east.connect.psdb.cloud',
      user: 'mpl0y3jv3a92h4qc4ufn',
      database: 'beam',
      password: 'pscale_pw_V8db13jnq5mrOWcGFn6GTs6AerDI7A0womsmnJ1qxOc',
      ssl_ca: '/etc/ssl/certs/ca-certificates.crt'
    }
  }

  const doc = `# Configure your application\n…`
  const ast = parse(doc)
  const content = transform(ast, config)
  const children = renderers.react(content, React, { components: { Fence } })

  return <div>{children}</div>
}

function Fence({ children, file, language }) {
  return (
    <div>
      <div>{file}</div>

      <pre>
        <code className={`language-${language}`}>children</code>
      </pre>
    </div>
  )
}

Fence.scheme = {
  render: Fence.name,
  children: ['pre', 'code'],
  attributes: {
    file: {
      type: String
    },
    language: {
      type: String
    }
  }
}

Further customizations

One challenge we have seen users face is deciding which SSL certificate to use when connecting securely to PlanetScale. To address this, we built a common component that will swap out the certificate based on the users detected operating system.

This also extends the snippet from the previous section, adding in functions to detect the user's operating system and return the correct string for the ssl_ca variable.

import React from 'react'
import { parse, renderers, transform } from '@markdoc/markdoc'

export default function Page({ userAgent }) {
  const platform = connectPlatform(userAgent)
  const sslCertificate = connectSslCertificate(platform)

  const config = {
    nodes: {
      fence: Fence.scheme
    },
    variables: {
      host: 'us-east.connect.psdb.cloud',
      user: 'mpl0y3jv3a92h4qc4ufn',
      database: 'beam',
      password: 'pscale_pw_V8db13jnq5mrOWcGFn6GTs6AerDI7A0womsmnJ1qxOc',
      ssl_ca: sslCertificate
    }
  }

  const doc = `# Configure your application\n…`
  const ast = parse(doc)
  const content = transform(ast, config)
  const children = renderers.react(content, React, { components: { Fence } })

  return <div>{children}</div>
}

function connectPlatform(userAgent) {
  userAgent = userAgent.toLowerCase()

  switch (true) {
    case /linux/.test(userAgent):
      return 'linux'
    case /mac/.test(userAgent):
      return 'mac'
    case /windows/.test(userAgent):
      return 'windows'
    default:
      return 'ubuntu'
  }
}

function connectSslCertificate(platform) {
  switch (platform) {
    case 'linux':
      return '/etc/ssl/certs/ca-certificates.crt'
    case 'mac':
      return '/etc/ssl/cert.pem'
    default:
      return '/etc/ssl/certs/ca-certificates.crt'
  }
}

function Fence({ children, file, language }) {
  return (
    <pre>
      <div>{file}</div>

      <code className={`language-${language}`}>children</code>
    </pre>
  )
}

Fence.scheme = {
  // …
}

Because a user's development environment is often different from their production environment, we also had to add a selector that allows users to select the certificate on their own. The final code for that is shown below.

import React, { createContext, useState } from 'react'
import { parse, renderers, transform } from '@markdoc/markdoc'

const Platform = createContext({ platform: null, setPlatform: () => {} })

export default function Page({ userAgent }) {
  const initialPlatform = connectPlatform(userAgent)
  const [platform, setPlatform] = useState(initialPlatform)

  const sslCertificate = connectSslCertificate(platform)

  const config = {
    nodes: {
      fence: Fence.scheme
    },
    variables: {
      host: 'us-east.connect.psdb.cloud',
      user: 'mpl0y3jv3a92h4qc4ufn',
      password: 'pscale_pw_V8db13jnq5mrOWcGFn6GTs6AerDI7A0womsmnJ1qxOc',
      ssl_ca: sslCertificate
    }
  }

  const doc = `# Configure your application\n…`
  const ast = parse(doc)
  const content = transform(ast, config)
  const children = renderers.react(content, React, { components: { Fence } })

  return (
    <Platform.Provider value={{ platform, setPlatform }}>
      <div>{children}</div>
    </Platform.Provider>
  )
}

function connectPlatform(userAgent) {
  // …
}
function connectSslCertificate(platform) {
  // …
}

function Fence({ children, file, language }) {
  const { platform } = useContext(Platform)

  const isDotEnvFile = file === '.env'
  const isWindowsPlatform = platform === 'windows'

  return (
    <div>
      <div>
        <div>{file}</div>

        {isDotEnvFile && (
          <select
            onChange={(event) => {
              setPlatform(event.target.value)
            }}
            value={platform}
          >
            <option value='linux'>Linux</option>
            <option value='mac'>macOS</option>
            <option value='windows'>Windows</option>
          </select>
        )}
      </div>

      <pre>
        <code className={`language-${language}`}>children</code>
      </pre>

      {isDotEnvFile && (
        <div>
          {isWindowsPlatform && (
            <>
              For Windows you may need to download a root certificate to connect securely.{' '}
              <a href='/docs/vitess/connecting/secure-connections#windows'>Learn more</a>
            </>
          )}
          {!isWindowsPlatform && (
            <>
              View the{' '}
              <a href='/docs/vitess/connecting/secure-connections#ca-root-configuration'>
                certificate authority root
              </a>{' '}
              paths for the SSL CA details.
            </>
          )}
        </div>
      )}
    </div>
  )
}

Fence.scheme = {
  // …
}

Outcomes using Markdoc

We are extremely happy with how the onboarding turned out, and based on some early data, it seems to be a huge win for new users as well. Working with Markdoc made the building process incredibly simple and straightforward. We're already finding that maintenance, like adding new frameworks, is very manageable as well.

We'd love to hear if you've been able to get your hands on Markdoc yet. If you'd like to experience our onboarding process first-hand, make sure you sign up for a PlanetScale account to give it a go.