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 🙏

© 2025 – Pkg Stats / Ryan Hefner

nuxt-civicrm

v0.0.2

Published

A Nuxt module that connects a Nuxt web application to a CiviCRM site via CiviCRM's REST API.

Readme

Nuxt CiviCRM integration

A Nuxt module that connects a Nuxt web application to a CiviCRM site. You can authenticate as a CiviCRM user and perform any API actions available to that user.

Nuxt CiviCRM is an early proof of concept and not yet ready for production - use at your own risk!

Overview

We are creating a set of set of Nuxt composables and components that interact with CiviCRM. Use them to build modern web experiences with Nuxt that are backed by CiviCRM's tried and tested API for data storage and functionality.

All requests to CiviCRM are proxied through the Nuxt server:

Note: Nuxt CiviCRM has been built for and tested with CiviCRM standalone. If you are interest in integrating Nuxt with a CiviCRM site on Drupal or WordPress, please create an issue and we can discuss the best approach.

Get started

The instructions below use pnpm. You can use your favourite node package manager.

Create a new Nuxt project.

pnpm create nuxt nuxt-civicrm-example

Tip: see the Nuxt getting started guide for more details on how to get up and running with Nuxt.

From the project directory, install the nuxt-civicrm module

pnpm add nuxt-civicrm

Add the nuxt-civicrm module to your Nuxt config file.

// nuxt.config.ts 
export default defineNuxtConfig({
  /// ...
  modules: [
    'nuxt-civicrm',
  ]
  /// ...
})

Add the URL of your CiviCRM site to the Nuxt runtime config.

Tip: you can use CiviCRM Buildkit Docker to quickly create a CiviCRM development environment if you don't already have one.

// nuxt.config.ts 
export default defineNuxtConfig({
  /// ...
  runtimeConfig: {
    civicrm: {
      url: 'http://localhost:7890'
    }
  }
  /// ...
})

In your CiviCRM site, configure authx as follows:

  • remove any options that are listed in Authentication guard (these aren't helpful in a Standalone context)
  • ensure that User Password is included as an option in Acceptable credentials (HTTP Session Login)

You should now be able use the useCivi() composable and <CiviLogin /> component in your Nuxt site.

Usage

The useCivi() composable returns an object with the following properties:

  • api async function to call the CiviCRM's REST API in the usual way
  • login async function to login with a CiviCRM username an password
  • logout async function to logout
  • user reactive reference for the currently logged in user (or null when logged out)

For example:

// Destructure useCivi() 
const {api, login, logout, user} = useCivi()

// Retrieve 10 contacts
const { data } = await api('Contact', 'get', {limit: 10})

// Login with a username and password
// Alternatively, try the <CiviLogin /> component)
await login('demo', 'demo')

// Logout
await logout()

Here is a single file component that demonstrates the user reactive reference.

<script setup lang="ts">
import { useCivi } from '../composables/useCivi'

// A reactive reference to the currently logged in user.
const { user } = useCivi()
</script>

<template>
  <div>
    <p v-if="user">You are logged in as {{ user.display_name }}.</p>
    <p v-else=>You are not logged in.</p>
  </div>
</template>

Technical details

Requests are proxied via a Nuxt server to avoid the need to set up CORS or 'third party' cookies.

Logging in sends a request to /civicrm/authx/login. If successful this creates a session and returns a cookie that we store in the browser and forward with subsequent requests.

Authorisation

There are various ways that you might want to connect a Nuxt application to a CiviCRM site. We have chosen the 'server-side' route. Below is a quick comparison of some alternatives.

  1. server-side - all communication is proxied via the Nuxt server (this is what is currently available)
  2. browser-side - all communication happens in the browser. Good when the Nuxt application and CiviCRM site are on the same domain but if they live on different domains you will need to think carefully about security, set up CORS headers and handle cookies appropriately.
  3. OAuth - not yet implemented but something that we would like to support in future. Let us know if you are interested in this.