Skip to content

Installation Guide

saleban olow edited this page Apr 24, 2025 · 1 revision

Installation Guide

This guide covers how to install Purgo in various environments and project types.

Basic Installation

You can install Purgo using npm, yarn, or pnpm:

# Using npm
npm install purgo

# Using yarn
yarn add purgo

# Using pnpm
pnpm add purgo

Browser Usage

For browser environments, simply import Purgo at the entry point of your application:

// Just import it - that's it!
import 'purgo';

This will automatically patch console methods, fetch, and XMLHttpRequest to redact sensitive information.

Node.js Usage

For Node.js environments, use the Node.js-specific import:

// Auto-patch process.stdout
import 'purgo/node';

Framework-Specific Installation

React

// In your entry file (e.g., main.jsx or index.jsx)
import 'purgo';
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';

ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

Next.js

// app/layout.tsx
import 'purgo';

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  );
}

Vue

// main.js
import 'purgo';
import { createApp } from 'vue';
import App from './App.vue';

createApp(App).mount('#app');

Vanilla JS (via script tag)

<script src="https://unpkg.com/purgo/dist/index.global.js"></script>
<script>
  // Purgo is automatically initialized
  console.log('Patient SSN: 123-45-6789'); // Outputs: "Patient SSN: ***"
</script>

Verifying Installation

To verify that Purgo is working correctly, you can run a simple test in your browser console or Node.js application:

console.log('Test email: patient@example.com');
console.log('Test SSN: 123-45-6789');

If Purgo is installed correctly, you should see the sensitive information redacted in the output.

Troubleshooting

If you encounter any issues during installation:

  1. Make sure you're using the latest version of Purgo
  2. Check that you're importing Purgo at the entry point of your application
  3. For Next.js, ensure you're importing in the correct layout file
  4. For Node.js, make sure you're using the purgo/node import

For more help, please open an issue on GitHub.

Clone this wiki locally