neondatabase / serverless

Connect to Neon PostgreSQL from serverless/worker/edge functions

Home Page:https://www.npmjs.com/package/@neondatabase/serverless

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use serverless in the browser?

ceving opened this issue · comments

I tried this, but serverless.mjs does not export neon.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <script type="module">
      // about:config -> security.fileuri.strict_origin_policy -> false
      import * as neon from './serverless/dist/serverless.mjs';
      console.log(neon);
      const url = 'postgresql://***';
      const sql = neon(url);
    </script>
  </head>
  <body>
  </body>
</html>

The output is just:

Array(4) [ "batchQueryTest", "cf", "latencies", "neonConfig" ]

Try import { neon } from './serverless/dist/npm/index.mjs'. Or use the npm package and bundle it in.

Thanks. This works!