Usage

Basic Usage

Learn how to use nuxt-coolify to interact with your Coolify instance.

Example

This guide demonstrates how to make API calls to your Coolify instance using Nuxt's useFetch composable.

app/app.config.ts
export default defineAppConfig({
  ui: {
    colors: {
      primary: 'sky',
      colors: 'slate'
    }
  }
})

Fetching Instances

Here's a basic example of how to fetch your Coolify instances:

<script setup lang="ts">
const { 
  data: instances, 
  pending, 
  error, 
  refresh: refreshInstanceList 
} = useFetch('/api/v1/coolify/instances')
</script>

<template>
  <div>
    <h2>Instances</h2>
    <div v-if="pending">
      Loading Instances...
    </div>
    <div v-else-if="error">
      Error: {{ error.message }}
    </div>
    <div v-else>
      <pre>{{ instances }}</pre>
    </div>
    <button @click="refreshInstanceList">
      Refresh Instances
    </button>
  </div>
</template>

Server side in Nitro

Create a endpoint in Nitro like below to return the Coolify Instances using the server composables:

~/server/api/v1/coolify/instances/[name]/index.get.ts
import type { Instance } from 'nuxt-coolify'

export default defineEventHandler(async (event) => {
  const name = getRouterParam(event, 'name')
  const { instances } = useRuntimeConfig().coolify

  // Do additional checks for user auth permissions here

  return useCoolify().instances(name as Instance)
})

Available Endpoints

The module provides several helpers that map to Coolify's API. Here are the available helpers organized by category:

Core Coolify Utilities

  • useCoolify().instances() - List all servers/instances
  • useCoolify().healthcheck() - Check instance health
  • useCoolify().version() - Get Coolify version
  • useCoolify().enableAPI() - Enable API access
  • useCoolify().disableAPI() - Disable API access

Applications

  • useCoolifyApplications().list() - List all applications
  • useCoolifyApplications().create() - Create new application
  • useCoolifyApplications().get() - Get specific application
  • useCoolifyApplications().update() - Update application
  • useCoolifyApplications().delete() - Delete application
  • useCoolifyApplications().logs() - Get application logs
  • useCoolifyApplications().listEnvs() - List application environments
  • useCoolifyApplications().createEnv() - Create environment variable
  • useCoolifyApplications().updateEnv() - Update environment variable
  • useCoolifyApplications().updateEnvsBulk() - Update multiple environment variables
  • useCoolifyApplications().deleteEnv() - Delete environment variable
  • useCoolifyApplications().start() - Start application
  • useCoolifyApplications().stop() - Stop application
  • useCoolifyApplications().restart() - Restart application

Projects

  • useCoolifyProjects().list() - List all projects
  • useCoolifyProjects().create() - Create new project
  • useCoolifyProjects().get() - Get specific project
  • useCoolifyProjects().update() - Update project
  • useCoolifyProjects().delete() - Delete project
  • useCoolifyProjects().environment() - Get project environment

Servers

  • useCoolifyServers().list() - List all servers
  • useCoolifyServers().create() - Create new server
  • useCoolifyServers().get() - Get specific server
  • useCoolifyServers().update() - Update server
  • useCoolifyServers().delete() - Delete server
  • useCoolifyServers().resources() - Get server resources
  • useCoolifyServers().domains() - Get server domains
  • useCoolifyServers().validate() - Validate server configuration

Databases

  • useCoolifyDatabases().list() - List all databases
  • useCoolifyDatabases().get() - Get specific database
  • useCoolifyDatabases().create() - Create new database
  • useCoolifyDatabases().update() - Update database
  • useCoolifyDatabases().delete() - Delete database
  • useCoolifyDatabases().start() - Start database
  • useCoolifyDatabases().stop() - Stop database
  • useCoolifyDatabases().restart() - Restart database

Services

  • useCoolifyServices().list() - List all services
  • useCoolifyServices().create() - Create new service
  • useCoolifyServices().get() - Get specific service
  • useCoolifyServices().update() - Update service
  • useCoolifyServices().delete() - Delete service
  • useCoolifyServices().listEnvs() - List service environments
  • useCoolifyServices().createEnv() - Create service environment variable
  • useCoolifyServices().updateEnv() - Update service environment variable
  • useCoolifyServices().updateEnvsBulk() - Update multiple service environment variables
  • useCoolifyServices().deleteEnv() - Delete service environment variable
  • useCoolifyServices().start() - Start service
  • useCoolifyServices().stop() - Stop service
  • useCoolifyServices().restart() - Restart service

Teams

  • useCoolifyTeams().list() - List all teams
  • useCoolifyTeams().get() - Get specific team
  • useCoolifyTeams().members() - Get team members
  • useCoolifyTeams().authenticatedTeam() - Get current authenticated team
  • useCoolifyTeams().authenticatedTeamMembers() - Get current team members

Private Keys

  • useCoolifyPrivateKeys().list() - List all private keys
  • useCoolifyPrivateKeys().create() - Create new private key
  • useCoolifyPrivateKeys().get() - Get specific private key
  • useCoolifyPrivateKeys().update() - Update private key
  • useCoolifyPrivateKeys().delete() - Delete private key

Deployments

  • useCoolifyDeployments().list() - List all deployments
  • useCoolifyDeployments().get() - Get specific deployment
  • useCoolifyDeployments().deploy() - Trigger deployment

You can find the complete API documentation on Coolify's API Reference page.

Next Steps

Join the Coolify Discord community to get help, share your experience, and stay updated with the latest developments.