-
Notifications
You must be signed in to change notification settings - Fork 0
Installation Guide
saleban olow edited this page Apr 24, 2025
·
1 revision
This guide covers how to install Purgo in various environments and project types.
You can install Purgo using npm, yarn, or pnpm:
# Using npm
npm install purgo
# Using yarn
yarn add purgo
# Using pnpm
pnpm add purgo
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.
For Node.js environments, use the Node.js-specific import:
// Auto-patch process.stdout
import 'purgo/node';
// 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>
);
// app/layout.tsx
import 'purgo';
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}
// main.js
import 'purgo';
import { createApp } from 'vue';
import App from './App.vue';
createApp(App).mount('#app');
<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>
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.
If you encounter any issues during installation:
- Make sure you're using the latest version of Purgo
- Check that you're importing Purgo at the entry point of your application
- For Next.js, ensure you're importing in the correct layout file
- For Node.js, make sure you're using the
purgo/node
import
For more help, please open an issue on GitHub.