open-index/open-npm huggingface dataset:
npm package: @foretag.dev/react-surreal
Description: A SurrealDB client for React, based on SurrealDB.js
Latest version: 0.1.3

# React Surreal

A SurrealDB client for React, based on SurrealDB.js

Currently supports React 18 and above.

## Usage
You can use this library with any React application / framework, here is an example with **NextJS 13 App Dir**.
```ts
// app/layout.tsx
'use client';

import React from 'react';

import Surreal from 'surrealdb.js';
import { SurrealProvider } from '@foretag.dev/react-surreal';

const db = new Surreal(process.env.NEXT_PUBLIC_SURREAL_HOST);

export default function RootLayout({ children, }: {
	children: React.ReactNode
}) {
	return <SurrealProvider
		database={db}
	>
		<html>
			<head></head>
			<body>

				{children}
			</body>
		</html>
	</SurrealProvider>
}
```

The following hooks are provided:

- `useAuth` - Handles authentication to SurrealDB, this exports: `signIn`, `signOut`, `signUp` methods & `isAuth`

```ts
import { useAuth } from '@foretag.dev/react-surreal';

const LoginPage = () => {
	// ...
	const { signIn, signOut, signUp, isAuth } = useAuth();
}
```

- `useQuery` - Queries to SurrealDB, this exports: `data`, `loading`, `error`, `refetch`, `status` & `time`

```ts
import { useQuery } from '@foretag.dev/react-surreal';

const AccountPage = () => {
	// ...
	const { data, loading } = useQuery('SELECT * FROM account');
}
```