FAQ
Basic Questions
Q: What is the difference between Lyt.js and Vue.js?
A:
- Zero dependencies: Lyt.js has no third-party dependencies at all, including its reactivity system, compiler, and renderer, all of which are self-developed
- Ultra-small bundle: Only 34.56KB gzipped, much smaller than Vue
- Vapor Mode: No virtual DOM mode, performance close to native
- Islands Architecture: SSR partial hydration architecture
- Learning curve: Closer to native HTML, simpler API
Q: Is Lyt.js suitable for production?
A: Lyt.js already has the foundation of a production-grade framework:
- Complete test suite (2436+ tests, 100% pass rate)
- Complete core functionality
- Stable API
- Comprehensive toolchain
However, please note:
- The ecosystem is still evolving
- The community is relatively small
- It lacks validation from large-scale production projects
Q: What is Lyt.js's browser compatibility?
A:
- Modern browsers: Chrome 60+, Firefox 55+, Safari 12+, Edge 79+
- Requires: Proxy, Reflect, Promise, Map, Set
- IE is not supported
Development Questions
Q: How do I migrate from Vue 3 to Lyt.js?
A: See the Migration Guide. The main changes:
typescript
// Vue 3
import { ref, reactive } from 'vue'
// Lyt.js
import { ref, reactive } from '@lytjs/reactivity'Q: How do I resolve "module not found" errors?
A:
- Make sure dependencies are installed:
npm install - Check import paths: Use the correct package name
@lytjs/core - TypeScript projects: Check the
pathsconfiguration intsconfig.json
Q: What if my component doesn't update?
A: Check the following:
- Make sure you are using reactive data (ref/reactive)
- Avoid replacing the entire reactive object
- When using
shallowRef, pay attention to how you update it - Check if the Key is set correctly
typescript
// Wrong
let data = reactive({ count: 0 })
data = { count: 1 } // Replaced the entire object, lost reactivity
// Correct
const data = reactive({ count: 0 })
data.count = 1 // Directly modify the propertyQ: How do I debug a Lyt.js application?
A:
- Use the built-in DevTools:
typescript
import { createDevTools } from '@lytjs/devtools'
app.use(createDevTools())- Use the browser DevTools debugging features
- Check console error messages
Performance Questions
Q: What if my application runs slowly?
A: See the Performance Optimization Guide. Check:
- Whether Vapor Mode is enabled
- Whether there is unnecessary deep reactivity
- Whether lists have the correct Key set
- Whether there are excessive DOM operations
- Use DevTools to analyze performance bottlenecks
Q: How do I optimize slow initial page loads?
A:
- Enable code splitting and lazy loading
- Use Vapor Mode
- Pre-compile templates
- Configure CDN and caching
- Use SSR/SSG
Q: What if memory usage is high?
A:
- Use
shallowRef/shallowReactive - Clean up event listeners promptly
- Be careful with caching strategies when using
KeepAlive - Avoid unnecessary reactive tracking
- Use
markRawto mark static data
Routing Questions
Q: What if History mode causes 404 on refresh?
A: You need to configure the server to support SPA fallback:
nginx
location / {
try_files $uri $uri/ /index.html;
}Q: How do I implement route guards?
A:
typescript
const router = createRouter({
routes
})
router.beforeEach((to, from, next) => {
// Check permissions
if (to.meta.requiresAuth && !isLoggedIn()) {
next('/login')
} else {
next()
}
})State Management Questions
Q: How do I persist Store data?
A:
typescript
import { defineStore } from '@lytjs/store'
export const useStore = defineStore('main', {
state: () => ({
count: 0
}),
persist: {
enabled: true,
storage: localStorage,
key: 'my-store'
}
})Q: How do I share state between multiple components?
A:
- Use a Store (recommended)
- Use Props and Events
- Use Provide/Inject
Build Questions
Q: What if the build fails?
A:
- Check the Node.js version (16+ recommended)
- Clear cache:
rm -rf node_modules package-lock.json && npm install - Check for TypeScript errors
- Review the build log
Q: How do I reduce the build size?
A:
- Enable Tree Shaking
- Use code splitting
- Remove unused imports
- Enable minification
- Use Vapor Mode
SSR Questions
Q: What if window is undefined during SSR?
A: Use client-side checks:
typescript
const isClient = typeof window !== 'undefined'
if (isClient) {
// Client-side code
}Q: How do I handle SSR data prefetching?
A:
typescript
export default {
async onServerPrefetch() {
const data = await fetchData()
return data
},
setup() {
const data = ref(null)
onMounted(async () => {
data.value = await fetchData()
})
return { data }
}
}Ecosystem Questions
Q: Is there a UI component library?
A: There is a basic component library @lytjs/components with common components:
- Button
- Input
- Select
- Modal
- Table
- And more
Q: How do I integrate with third-party libraries?
A: Most third-party libraries can be used directly:
typescript
import axios from 'axios'
import dayjs from 'dayjs'
const response = await axios.get('/api/data')Contributing Questions
Q: How can I contribute to Lyt.js?
A:
- See the Contributing Guide
- Submit an Issue to report problems
- Submit a Pull Request to improve the code
- Improve documentation
- Share your experience
Q: How do I report a Bug?
A:
- Submit an Issue on the Gitee repository
- Provide reproduction steps
- Provide a minimal reproduction code
- Describe the expected and actual behavior
Future Plans
Q: What is Lyt.js's development roadmap?
A: See the Roadmap. Main plans:
- Improve the ecosystem
- More official plugins
- Developer tool improvements
- Performance optimization
- Documentation improvements
Q: Will there be first-class TypeScript support?
A: Yes, Lyt.js is developed entirely in TypeScript and provides complete type definitions.
More Resources
Have other questions? Feel free to submit an Issue on the Gitee repository!