Create Varity App
Create Varity App is a command-line interface (CLI) tool designed to bootstrap production-ready web applications with integrated authentication, database, storage, and payment capabilities. Functioning as an 'all-in-one' platform, Varity aims to significantly reduce development and deployment time, boasting '60-second deploys' and claiming 60-80% cost savings compared to traditional cloud setups like AWS. It achieves this through a 'zero-configuration' approach for core services, leveraging internal packages such as `@varity-labs/sdk` for backend interactions and `@varity-labs/ui-kit` for frontend components. The package is currently in a beta state, version `2.0.0-beta.22`, indicating active development and a rapid release cadence for new features and improvements. It targets developers building SaaS products, dashboards, or any web application requiring robust foundational features without extensive manual setup. Key differentiators include its unified platform experience, emphasis on developer experience with React and TypeScript, and a marketplace for monetization.
Common errors
-
command not found: create-varity-app
cause The `create-varity-app` package is typically executed via `npx` and is not installed globally or directly in the system's PATH.fixAlways use `npx create-varity-app my-app` to execute the package, which downloads and runs the latest version without global installation. -
TypeError: Cannot read properties of undefined (reading 'collection') when using `db`
cause The Varity SDK's database client (`db`) might not be initialized correctly, or the application is running outside the Varity environment where it expects automatic configuration.fixEnsure the application is running within the Varity-generated project structure and that all necessary environment variables or configurations are in place as expected by the SDK's 'zero-config' setup. Check Varity documentation for explicit initialization steps if running outside a typical Varity app. -
Failed to authenticate / Login fails unexpectedly with AuthProvider or LoginButton
cause Authentication issues in a Varity app can stem from incorrect Varity platform configuration (e.g., app ID, API keys), network issues preventing communication with Varity auth services, or misconfiguration of social login providers.fixVerify that your Varity project is correctly configured on the Varity platform. Check console logs for network errors or specific authentication error messages. Ensure that the `AuthProvider` wraps your application's components as per documentation.
Warnings
- gotcha The `create-varity-app` package and the underlying Varity platform are currently in a `2.0.0-beta.22` state. This indicates active development where APIs, features, and stability might change without strict adherence to semantic versioning for non-major releases, potentially leading to breaking changes between beta versions. Use in production with caution.
- gotcha While Varity is advertised as an all-in-one platform including payments, the documentation explicitly states that 'Payments (coming soon)' or that the 'PaymentWidget' is for 'post-beta' availability. This means the payments functionality may not be fully implemented or production-ready despite being part of the SDK/UI kit. This could lead to unexpected roadblocks for apps requiring immediate payment processing.
- gotcha The Varity ecosystem includes both a JavaScript `create-varity-app` (via `npx`) and a Python `varitykit` CLI (via `pip`). Mixing these CLIs or misunderstanding their respective roles could lead to confusion or environment setup issues, especially regarding deployment commands (`varitykit deploy`).
Install
-
npm install create-varity-app -
yarn add create-varity-app -
pnpm add create-varity-app
Imports
- create-varity-app
import createVarityApp from 'create-varity-app'
npx create-varity-app my-app
- db
import { database } from '@varity-labs/sdk'import { db } from '@varity-labs/sdk' - AuthProvider
import { Auth } from '@varity-labs/ui-kit'import { AuthProvider } from '@varity-labs/ui-kit' - LoginButton
import { ButtonLogin } from '@varity-labs/ui-kit'import { LoginButton } from '@varity-labs/ui-kit'
Quickstart
npx create-varity-app my-awesome-app
cd my-awesome-app
npm install
npm run dev
// Example of using SDK within the created app (e.g., in a React component or API route):
import { db } from '@varity-labs/sdk';
import { AuthProvider, LoginButton } from '@varity-labs/ui-kit';
function MyAppComponent() {
const handleAddPost = async () => {
const posts = db.collection('posts');
const newPost = await posts.add({
title: 'My First Varity Post',
content: 'Hello, Varity world!',
authorId: 'user-123' // Replace with actual user ID from auth context
});
console.log('Added post:', newPost);
};
return (
<AuthProvider>
<div>
<h1>Welcome to Varity!</h1>
<LoginButton />
<button onClick={handleAddPost}>Add Example Post</button>
</div>
</AuthProvider>
);
}