npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@skillrecordings/convertkit-react-ui

v0.0.3

Published

## Next.js API routes

Downloads

4

Readme

Skill Recordings Convertkit Utils

Next.js API routes

POST /api/convertkit/subscribe

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

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

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:

/* ——— 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;
  }
}