Skip to content

Commit

Permalink
update next.js demo (#362)
Browse files Browse the repository at this point in the history
Signed-off-by: shanghaikid <jiangruiyi@gmail.com>
  • Loading branch information
shanghaikid authored Oct 1, 2024
1 parent d9c4aaf commit 37f9a51
Show file tree
Hide file tree
Showing 3 changed files with 253 additions and 76 deletions.
25 changes: 21 additions & 4 deletions examples/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { MilvusClient } from '@zilliz/milvus2-sdk-node';

async function getData() {
async function getData(address: string) {
const milvusClient = new MilvusClient({
address: 'localhost:19530',
address,
});

let res: any = await milvusClient.getMetric({
Expand All @@ -17,7 +17,24 @@ async function getData() {
}

export default async function Home() {
const data = await getData();
const address = `10.102.5.223:19530`;

return <>{JSON.stringify(data)}</>;
const data = await getData(address);

return (
<div className="min-h-screen flex items-center justify-center bg-gray-100">
<div className="max-w-4xl w-full p-6 bg-white rounded-lg shadow-md">
<h1 className="text-3xl font-bold text-center mb-4">
Welcome to Milvus
</h1>
<h2 className="text-xl font-bold text-center mb-4">{address}</h2>

<div className="bg-gray-50 p-4 rounded-lg">
<pre className="whitespace-pre-wrap text-sm text-gray-800">
{JSON.stringify(data, null, 2)}
</pre>
</div>
</div>
</div>
);
}
10 changes: 6 additions & 4 deletions examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
"lint": "next lint"
},
"dependencies": {
"@zilliz/milvus2-sdk-node": "^2.4.3",
"next": "^14.2.4",
"react": "^18",
"react-dom": "^18"
"@uiw/react-codemirror": "^4.23.3",
"@zilliz/milvus2-sdk-node": "^2.4.9",
"codemirror": "^6.0.1",
"next": "^14.2.13",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@types/node": "^20",
Expand Down
Loading

0 comments on commit 37f9a51

Please sign in to comment.