# @skillrecordings/convertkit-react-ui

> ## Next.js API routes

Latest version **0.0.3** (published 2023-11-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install @skillrecordings/convertkit-react-ui
pnpm add @skillrecordings/convertkit-react-ui
yarn add @skillrecordings/convertkit-react-ui
bun add @skillrecordings/convertkit-react-ui
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2023-11-28 |
| First published | 2023-07-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 74.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Joel Hooks |
| Maintainers | evgeniy.egghead, joelhooks, vojtaholik |

## Links

- npm: https://www.npmjs.com/package/@skillrecordings/convertkit-react-ui
- npm.io page: https://npm.io/package/@skillrecordings/convertkit-react-ui

## Dependencies (11)

- [yup](https://npm.io/package/yup.md) ^0.32.11
- [axios](https://npm.io/package/axios.md) ^1.4.0
- [cookie](https://npm.io/package/cookie.md) ^0.5.0
- [formik](https://npm.io/package/formik.md) 2.2.9
- [js-cookie](https://npm.io/package/js-cookie.md) ^3.0.1
- [react-use](https://npm.io/package/react-use.md) ^17.3.2
- [query-string](https://npm.io/package/query-string.md) ^7.1.1
- [@reach/dialog](https://npm.io/package/@reach/dialog.md) ^0.16.2
- [@skillrecordings/axios](https://npm.io/package/@skillrecordings/axios.md) =0.0.2
- [@skillrecordings/react](https://npm.io/package/@skillrecordings/react.md) 1.0.2
- [@skillrecordings/config](https://npm.io/package/@skillrecordings/config.md) 0.0.3

## Recent versions

- 0.0.3 (latest) — 2023-11-28
- 0.0.2 — 2023-07-20

## README

# Skill Recordings Convertkit Utils

## Next.js API routes

### POST /api/convertkit/subscribe

Add `/pages/api/convertkit/subscribe.ts` and update it to:

```typescript
import convertkitSubscribeHandler from '@skillrecordings/convertkit-react-ui'

export default convertkitSubscribeHandler

```

#### Environmental Variables

 - `NEXT_PUBLIC_CONVERTKIT_SIGNUP_FORM`: The Convertkit form ID to use for signup.
 - `NEXT_PUBLIC_CONVERTKIT_TOKEN`: The Convertkit PUBLIC API token to use.
 - `NEXT_PUBLIC_CONVERTKIT_SUBSCRIBER_KEY`: The Convertkit subscriber key to use (default value is `ck_subscriber_id`)

## React Components and Hooks

### Subscribe to a convertkit form

This package exports `SubscribeToConvertkitForm`

The form submits to `/api/convertkit/subscribe`

```typescript jsx
import * as React from 'react'

import {
  redirectUrlBuilder,
  SubscribeToConvertkitForm,
} from '@skillrecordings/convertkit-react-ui'
import {useRouter} from 'next/router'

const CallToActionForm: React.FC<any> = ({content}) => {
  const router = useRouter()

  return (
    <SubscribeToConvertkitForm
      actionLabel={content.button}
  onSuccess={(subscriber: any) => {
    if (subscriber) {
      const redirectUrl = redirectUrlBuilder(subscriber, '/confirm')
      router.push(redirectUrl)
    }
  }}
  />
  )
}

export default CallToActionForm
```

#### styling the form

You'll need to add CSS to style the form. Internally this is using the `Input` and `Button` components from `@skillrecordings/react`. The form itself exposes `data-sr-convertkit-subscribe-form` and allows you to style the containing for
appropriately.

* `data-sr-convertkit-subscribe-form`: the `form` element
* `data-sr-button`: the submit button
* `data-sr-button-icon`: icon on the button, a spinner while loading
* `data-sr-input-wrapper`: a container around the `input` and `Label`
* `data-sr-input-asterisk`: the "required" indicator
* `data-sr-input`: the actual `input` itself
* `data-sr-input-label`: the `label` associated with the input

Here's an example:

```css
/* ——— subscribe form ——— */

[data-sr-convertkit-subscribe-form] {
  @apply w-full max-w-sm mx-auto flex flex-col;
  [data-sr-input] {
    @apply autofill:text-fill-black dark:autofill:text-fill-white autofill:caret-black dark:autofill:caret-white dark:bg-black w-full text-lg py-2 px-4 leading-7 border-gray-200 rounded-md autofill:border-violet-400 focus:ring-violet-400 focus:ring-2 focus:outline-none focus:border-transparent placeholder-gray-400 mb-4;
  }
  [data-sr-input-label] {
    @apply block text-base pb-1;
  }
  [data-sr-button] {
    @apply self-center font-medium text-lg rounded-full focus:bg-gray-500 focus:ring-2 focus:scale-90 focus:ring-black hover:scale-105 transition-all hover:shadow-xl focus:outline-none mt-4 sm:px-16 px-14 py-4 bg-gradient-to-r dark:from-pink-500 dark:to-purple-500 from-violet-500 to-pink-500 text-white ease-in-out;
  }
  [data-sr-input-asterisk] {
    @apply text-fuchsia-400 dark:text-fuchsia-400;
  }
}
```

---
_Source: https://npm.io/package/@skillrecordings/convertkit-react-ui · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
