Comments (6)
Hi @KaiSpencer
You can use the new API in Wranlger to make it more easy. See here: #39 (comment)
from honox.
Thanks for your patience guys!
I have managed to get this working with using wrangler d1 execute
with the following configuration
Key changes:
d1Databases - explicitly state ID of database as per wrangler.toml
d1Persist - set to directory as wrangler d1 execute runs
honox({
devServer: {
plugins: [
pagesPlugin({
d1Databases: { DB: "c1ec051a-3e19-4c89-92fa-bdc2b3f69e1c" },
d1Persist: "./.wrangler/state/v3/d1",
}),
],
},
}),
from honox.
Hi.
If you write d1Databases and d1Persist entries in Vite config as the sample repo, the DB schema at startup is made at ./.mf/d1/{D1_Binding_Name}/db.sqlite
// vite.config.ts
import pages from '@hono/vite-cloudflare-pages'
import pagesPlugin from '@hono/vite-dev-server/cloudflare-pages'
import honox from 'honox/vite'
import client from 'honox/vite/client'
import { defineConfig } from 'vite'
export default defineConfig(({ mode }) => {
if (mode === 'client') {
return {
plugins: [client()],
}
}
return {
plugins: [
honox({
devServer: {
plugins: [
pagesPlugin({
d1Databases: ['DB'],
d1Persist: true,
}),
],
},
}),
pages(),
],
}
})
Optimizations for these migrate, seed, and uses vary as they depend on the query builder everyone uses, but it would be nice if this specification is clearly stated in the README or in a future Doc.
from honox.
I do not think it is unreasonable to expect the wrangler
commands to manipulate D1 to work with honox, especially given the deploy command is using the wrangler
CLI too.
from honox.
It works fine you just need to configure HonoX correctly. I am currently using it within a project. d1persist
can also be a string to configure a custom location.
You just have to change the directories to match wherever you are pointing wrangler. In my case, I put .wrangler
in the root of a mono-repo.
I agree that more documentation is needed around this.
const serversidePlugins = [
tsconfigPaths(),
honox({
devServer: {
cf: {
d1Databases: { TORCH_DATABASE: 'TORCH_DATABASE' },
d1Persist: '../../.wrangler/state/v3/d1',
r2Buckets: ['TORCH_R2'],
r2Persist: '../../.wrangler/state/v3/r2',
kvNamespaces: ['TORCH_AUTH'],
kvPersist: '../../.wrangler/state/v3/kv',
},
},
}),
pages(),
];
from honox.
Hi @KaiSpencer
You can use the new API in Wranlger to make it more easy. See here: #39 (comment)
Thank you so much @yusukebe
Works perfectly, much simpler too!
from honox.
Related Issues (20)
- Ignore files having `$` as a prefix for routes
- Idea: Route-based API ? HOT 1
- Does it support wasm? HOT 6
- Add documentation on how to use HonoX outside of Cloudflare HOT 2
- Internal server error: Can't find variable: require HOT 2
- honox + auth.js HOT 2
- `onClick` doesn't "work"
- Better `EventAttributes` types HOT 1
- Issue with Vite and @azure/storage-blob Package HOT 6
- Cloudflare dependencies is included when is not used HOT 1
- valtio not working HOT 2
- development server take too long time
- Unable to use cookies through `hono/cookie` HOT 3
- Can't merge type of props for React renderer
- Support CDN baseUrl in `<Script>`
- Documentation - Starter Template - No x-basic option in hono-create command HOT 2
- HMR support for react renderer
- Vite plugin for sitemap.xml generation in SSR mode for HonoX
- Where should static assets be stored?
- HTMX Compatibility HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from honox.