From Neon database to supabase (using Drizzle ORM)

Hi everyone,
I'm migrating a Next.js application (v14.1.3) using Drizzle ORM (v^0.30.2) from Neon Database to Supabase.

Steps Taken:
  1. Updated the database URL in my .env file.
  2. Modified db/drizzle.ts to use Supabase with the following code:
    ```typescript
    import { drizzle } from 'drizzle-orm/postgres-js'
    import postgres from 'postgres'
    import * as schema from "./schema"
const connectionString = process.env.DATABASE_URL as string;

const client = postgres(connectionString, {max: 1})

const db = drizzle(client, {schema});

export default db;
The above changes resulted in the following error:

cloudflare:sockets

Module build failed: UnhandledSchemeError: Reading from "cloudflare:sockets" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "cloudflare:" URIs.

Import trace for requested module:
cloudflare:sockets
./node_modules/postgres/cf/polyfills.js
./node_modules/postgres/cf/src/index.js
./db/drizzle.ts
./lib/auth.ts
I was able to resolve the issue by adding an IgnorePlugin to the Next.js configuration (`next.config.mjs`):
js
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (config, { webpack }) => {
config.plugins.push(new webpack.IgnorePlugin({
resourceRegExp: /^pg-native$|^cloudflare:sockets$/,
}));

return config;
},
// ... other Next.js configuration
};

export default nextConfig;
```
Was this page helpful?