This project is work-in-progress, then it can introduce any breaking changes. Please, use it with caution.
Welcome to the SvelteKit Boilerplate! This project provides a solid foundation for building web applications with SvelteKit, along with security features and compatibility with Cloudflare services.
src/server/db
directory)To get started, clone the repository and install the dependencies:
git clone https://github.com/bchainhub/dapp-sveltekit-boilerplate.git
cd dapp-sveltekit-boilerplate
npm install
Start the development server:
npm run dev
Build the project for production:
npm run build
Preview the production build:
npm run preview
Update the vite.config.ts
file located in the main folder to customize the project settings.
You can customize application settings in wrangler.toml
file:
NODE_VERSION
: Node.js version.Environment variables are stored in the .env
file. You can add your own environment variables to this file.
CLOUDFLARE_ACCOUNT_ID
: Cloudflare account ID.CLOUDFLARE_API_TOKEN
: Cloudflare API token.CAPTURE_COUNTRY
: Provide country as a variable from CF pages, Netlify, Vercel. If enabled.CAPTURE_CITY
: Provide city as a variable from CF pages, Netlify, Vercel. If enabled.Public variables:
PUBLIC_ENABLE_AUTH
: Enable or disable authentication. Default is false (disabled).Environment variables for database setup:
DB_TYPE
: Database type: SQLite, PostgeSQL. Default is no database (empty string).DB_URL
: Database URL.DB_AUTH_TOKEN
: Database authentication token.DB_SSL
: Enable or disable SSL for Postgres database.Web4 is the tool for connecting to the offline blockchain data and ecosystem using specialized devices. You can use it for blockchain operations and interaction using radio frequencies. Native support for Web4 is included in the project.
Currently, we are supporting the following functionality:
What is Web4?
In short Web4 is an alternative network and operations instead of the Internet. It is a secure and reliable way to interact with the blockchain data. You can use it for blockchain operations and interaction using radio frequencies as well as 0G connectivity. But it is not focused only on Blockchain, can it be various types of data.
Why do you need Web4?
In some cases you need to interact with the blockchain data offline. You can use Web4 + Web3 for this purpose. It is a secure and reliable way to interact with the blockchain data. You can use it for blockchain operations and interaction using radio frequencies as well as 0G connectivity.
The project is a Progressive Web Application (PWA) by default. You can customize the PWA settings in the vite.config.ts
file.
The project uses TailwindCSS for styling. You can customize the styles by editing the tailwind.config.js
file.
Custom styles and variables are defined in the src/css
directory. You can use customization tool to edit variables. We are using prefix skc
for custom classes.
You can use tool to generate TailwindCSS colors: TailwindCSS Color Generator or TailwindCSS Color Shades.
Types of connectors:
We are recommending purchasing the Hyperdrive connector for production use. There are many advantages and you can bind plenty of databases.
You can use SQLite, Postgres database, or any other supported by Drizzle. Supported drivers by Cloudflare are listed here. The database setup is defined in the .env
file prefixed with DB_
.
The project uses Drizzle ORM for database setup. You can find more information in the Drizzle ORM documentation.
This step is optional, but required for authentication and blockchain operations.
We are supporting three categories of databases:
Drizzle setup is located in the drizzle.config.ts
file. Configure it for your database setup.
Schemas are located in the src/schemas
directory. You can add your own schema files.
We are recommending to use the following setup:
If you own the Orb device, you can use it for blockchain operations. You can use the D1 database for ordinary operations. You can use the Hyperdrive connector for production use - for Apps they need the heavy load.
The project uses CorePass Extension for authentication but Passkey is possible to build also.
Dependencies:
Sitemaps help search engines prioritize pages within your site, particularly when you have a large amount of content. You can create a sitemap dynamically using an endpoint: src/routes/sitemap.xml/+server.ts
export async function GET() {
return new Response(
`
<?xml version="1.0" encoding="UTF-8" ?>
<urlset
xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="https://www.w3.org/1999/xhtml"
xmlns:mobile="https://www.google.com/schemas/sitemap-mobile/1.0"
xmlns:news="https://www.google.com/schemas/sitemap-news/0.9"
xmlns:image="https://www.google.com/schemas/sitemap-image/1.1"
xmlns:video="https://www.google.com/schemas/sitemap-video/1.1"
>
<!-- <url> elements go here -->
</urlset>`.trim(),
{
headers: {
'Content-Type': 'application/xml'
}
}
);
}
About Platform Environment Variables:
PUBLIC_
.We can access local environment variables using the env
function. This function is used to read the environment variables from the .env
file. Any value is returned as string
.
Contributions are welcome! For feature requests, bug reports, or questions, please open an issue.
This project is open source and available under the CORE License.