When starting with the DocLayer Boilerplate, search functionality is already included and ready to use. You can simply configure it as you like and you're all set. However, the dl-search module, which handles search-related logic and the AI Assistant, can also be installed in a standalone Nuxt app, even without DocLayer. Below you'll find a guide on how to install and configure it. This can also serve as a useful reference for how the module is used with the Boilerplate app.
Installation
Install dl-search module into your Nuxt application.
As package versions may vary the most current ones can be found in the package.json file of the main DocLayer Boilerplate repository.
Just after, initialize the module within the nuxt.config.ts file.
You can configure the module by adding a dlSearch key to your nuxt.config.ts file. However, for the simplest use cases, no configuration is required - the module works out of the box.
This is how to initialize it with configuration:
Full-text search usage
The simple full-text search doesn’t require any special setup - it can be used right away with the predefined composable. However, the AI Assistant requires a more advanced setup to ensure optimal performance and predictable behavior. Let’s begin by looking at simple full-text search.
Here is an example on how to use the full-text search:
As shown above, the full-text search is initialized by calling the useDlSearch composable, which returns a callback function, registering one instance of the Fuse.js. This function accepts a search query and returns an array of search results that you can handle within the UI.
Dedicated search format
The content index is structured with the page URL as the key. This means that when you search, the Fuse uses a string in the format [page path]:[page content], ensuring that the most relevant content matching your query is returned along with the correct path to the page you should visit.
Options
Below are the default options used for the Fuse.js instance.
You can also provide your own options to the search function to customize the search behavior; any defaults will be overridden by the values you specify.
External data source
If you don't want to use the content index, you can provide your own data source to the search function. This can be useful if you want to search a different data source, such as a database or an API.
AI-powered search usage
Since AI-powered search (AI Assistant) is disabled by default, you need to enable it before you using it. To do this, two environment variables must be set:
DL_SEARCH_ASSISTANT- set to'true'to enable the AI AssistantDL_SEARCH_ASSISTANT_HFC- URL of the Hugging Face CDN
You can also control the assistant programmatically using assistant.enabled option in the module configuration.
Why do we use a CDN? The AI Assistant is disabled by default and may not be needed by every user, so we do not include all of its assets in the final application build. Also, not all users have fast internet connections to download large files quickly. By using a CDN, these assets are downloaded only when needed or permitted, and can then be cached for future use. This approach makes the solution both efficient and cost-effective.
Selecting the operational model
By default, the AI Assistant operates locally and does not reach out to any external services to answer questions (prompts) about the content. The model used to generate answers is intentionally small and further compressed for optimal performance. While this enables fast, private, and efficient responses, it is important to note that the assistant works best when given focused, relevant context. The more precise and less noisy context it gets, the better the answers it can provide. This setup is especially effective for straightforward content like blogs. Note that the answers will tend to be concise and focused, rather than broad and verbose. More about local model configuration, you can read here.
The second option is to use a remote model. In this approach, you call an external API to answer questions (prompts) about the content. With the proper infrastructure, this enables handling user's queries and retrieving comprehensive, detailed answers that cover the most relevant information about your content. More about preferred model configuration, you can read here.
For remote-based models we're exposing the dedicated AI Kit, which includes advanced features such as the enhanced Chat component, content caching, conversation history, and more. You can preview and test these features using this application's AI Assistant.
DocLayer's Remote Model
DocLayer offers a prebuilt remote API for the AI Assistant, providing advanced features like context focusing, deterministic intelligent caching, and optimized code extraction to deliver precise, high-quality answers (almost) every time.
Our carefully fine-tuned model is available through the 🫠 Early Supporter Program - help us to build the best product possible securing the most advanced features for the best price.
Here’s how you can configure it:
To try our API please contact us. It's free.
Remote API operates with a dedicated DocLayer AI Kit.
Preparation process
Note that this step of the process is covered by the DocLayer Boilerplate application and does not need to be done manually.
After enabling the Assistant, a dedicated preparation process must be triggered. During this process, several actions are carried out:
- checking the user's network speed is sufficient to download the assets,
- downloading the assets from the CDN,
- caching the assets in the browser,
- initializing the Hugging Face pipelines.
To initialize the preparation process use a dedicated prepare function:
The prepare function accepts a status reference as an argument. This reference is used to dynamically track the preparation process and to determine if the preparation was successful.
Second argument is the networkSpeedBoundary option. This option is used to determine if the user's network speed is sufficient to download the assets. If the user's network speed is below the boundary, the preparation process will be aborted. Default value is set to 5 MBps. This value can be also set trough the module configuration.
Initialize as soon as possible
Because the preparation process involves several intensive tasks, it's best to initialize it as early as possible - ideally as soon as the user interacts with the application. Since the Search component is mounted within the Header component, this is often an ideal place to trigger the initialization.
Now, if the detected network speed is below the specified boundary, the preparation process will be aborted: no assets will be downloaded, and the assistant will be disabled. In this case, the assistantStatus reference is set to the rejected state.
If the network speed meets or exceeds the boundary, the preparation process continues and the assistantStatus reference is updated to the initialized state. While in this state, required assets such as models and data embeddings are downloaded and cached in the browser, all performed in the background.
Watching the assistantStatus reference allows you to dynamically update the UI and handle the assistant state accordingly. You can use it to determine if the assistant is enabled or disabled, and to show a loading state or an error message if the preparation process fails.
Finally, if the preparation process is successful, the assistantStatus reference is updated to the finished state. This state indicates that the assistant is fully initialized and ready to be used. 🎉 Any kind of the assistant state will be saved within the dedicated cookie.
Resolving user's questions with the AI Assistant
Note that this step of the process is covered by the DocLayer Boilerplate application and does not need to be done manually.
Now that we have assistant prepared nad ready to use, we can start resolving user's questions. To do this, we need to use the prompt function:
The prompt function returns an array of results. Each result contains an answer as a string and a dedicated meta data object. If you are using an external API, the answer may be returned in Markdown format. In this case, the UI converts the Markdown content to an AST for rendering. The default Search component handles this automatically.
If you need to convert Markdown to an AST manually within your new, custom components, you can use the utilMDtoHAST utility. Further rendering can then be handled by the DlRenderer component.
That's it - the rest is up to you! Everything is managed in the UI, giving you complete control over the assistant's behavior and how model answers are displayed. And remember, if you're starting with the DocLayer Boilerplate, all of this functionality comes ready to use out of the box.
On the next page you can learn how to configure the entire module for different scenarios, giving you complete control and flexibility - whether you’re using it with the Boilerplate or in a standalone Nuxt application.
Writing content for the AI Assistant
It's important to emphasize that the AI Assistant is not a magic tool capable of answering any question. It's powered by a model, and its context is "limited" to the content that has been indexed. For this reason, you should write content that is both easy to find within that context by a given question - and easy for the AI Assistant to extract and use in its answers.
Best practices for authoring content for the AI Assistant:
- Use clear and concise language. Avoid complex sentences and jargon. Opt for simple words and phrases to ensure maximum accessibility for all users.
- Be explicit and specific. Refrain from using shortcuts, and regularly mention your product or service name to provide explicit context. Aim to be as specific as possible, especially in sections where technical content might be challenging for some readers.
- Keep your users in mind. The more understandable and user-focused your content, the more effective the AI Assistant will be in delivering relevant answers.
- Structure content carefully. Consider your documentation as an interface for the AI Assistant. The clearer and more precise your content is, the more effectively the AI can interpret, build upon, and deliver helpful information.
- Use hidden prompts for extra context. A useful technique is to use the
DlPromptercomponent to add supplementary context just for the Assistant. This information will remain invisible to regular users. - Keep sections focused on a single topic.
- Avoid mixing different content topics within the same section of your documentation.
- When unrelated concepts (such as deployment instructions and development setup) appear together, the Assistant may extract context that answers a different question than intended. For example, mentioning "how to deploy" inside a section about "running in development" could cause the Assistant to answer deployment questions with development instructions, simply because both topics are present in the same indexed context.
- To improve the accuracy of AI-powered answers, try to keep content sections focused on a single topic, splitting out unrelated details into clearly separated pages or sections. This helps ensure the context retrieved for a user prompt is specific and relevant to the question being asked.
- If you need to include multiple topics within a single section, you can prevent certain content from being indexed for search by wrapping it in escape tags. For example:
[[ esc ]] escaped content goes here [[ /esc ]].
- Leverage available tools. Through our 🫠 Early Supporter Program, you can access tools to help you prepare your content for the Assistant and understand how it’s interpreted.
Advanced
Below we've gathered a few important insights that may help you better understand how the dl-search module works and how it interacts with your content. While a deep understanding isn't required, it's helpful to have some knowledge of what happens behind the scenes.
Assets
During template generation process, the module reads the compressed Nuxt Content database, parses and resolves each configured collection, and writes under public/.doclayer/. The following artifacts are generated and/or shipped:
| Artifact | Role |
|---|---|
_content.json.gz | Flattened, preprocessed and compressed searchable text. |
_vectors.json.gz | Compressed embedding vectors. |
| Models | Quantized weights consumed by the transformers. |
For the local Assistant, module will ship two quantized models along with their tokenizers and configuration files, delivered directly via the Hugging Face CDN:
| Model role | Bundled Size |
|---|---|
Embeddings | ~33 MB / ~23 MB |
Question-answering model | ~43 MB |
By default, when you use the AI Assistant with local mode, around 95 MB of model files will be added to your published app. This includes both the main question-answering model and the embedding model; if you opt for the smaller all-mini, the combined size drops to about 85 MB. These figures do not include the extra search data files - like _content.json.gz, _vectors.json.gz, code references, or small runtime helpers - which have negligible impact on total size. Remote-based mode gets only embeddings model.
It is very important to understand that managing these AI models and indexing assets happens through an asynchronous process, using a dedicated prepare mode that runs in the background. This design allows your app to fetch and process large assets without blocking the main thread, so asset preparation and content indexing can smoothly complete without interfering with your normal site workflow. Additionally users with poor network conditions will never experience this as the whole process will be blocked.
At runtime, the client fetches all required resources from public destination, including compressed vectors. All core Hugging Face assets - such as the transformers runtime, tokenizers, and any remote artifacts used during the preparation process - are delivered directly via the Hugging Face CDN defined by DL_SEARCH_ASSISTANT_HFC. Only the models you specifically bundle are loaded from your app’s public directory; all other assets are streamed efficiently from the CDN, ensuring quick and reliable access to the most up-to-date versions. Eventually, if your app is hosted on a CDN, all of your application’s assets will also be delivered from the edge for improved performance.
Separate from search generation, DocLayer's Markdown pipeline emits code-references under public/.doclayer/cref directory. The Assistant consumes those files when resolving cref markers.
Native browser-based models
Currently we're working/experimenting on the native browser-based models, which will allow to use the AI Assistant without any external dependencies.
Performance
Full-text search uses Fuse.js on top of an indexed content structure, which is stored as a compressed resource accessed from the browser. This approach is inherently fast and efficient. You can experiment with different Fuse.js options to optimize search speed and relevance for your application.
The AI Assistant enhances search using a multi-step retrieval process. When the user asks a question, the system first identifies the most relevant content sections based on how similar they are to your user's query. It then refines this context, selecting the most meaningful text segments to build the final answer. Adjustable settings (like how many sections to include) allow you to balance accuracy and performance, but in general, using fewer, well-written sections leads to the best results.
Compression
At build time, the content assets are compressed before being placed in the application's public location, which makes the shipped content index and vectors much smaller than the raw format. At runtime, the client fetches this data and decompresses it on the fly, then further caches for future use. Each time new content is delivered, it is revalidated, so try to be restrained with delivering updated content. If you need to investigate the content assets, you can set debug.compression to true in the module configuration, which will disable compression of the assets.
Caching
When you first use the search or assistant, module gets everything it needs ready ahead of time. To make things fast for users, these files are saved in the browser’s storage (double-checked to make sure they’re up to date). That way, visitors don’t have to keep downloading large files on every visit. The system also makes sure that when you reload or update your site, you always get the newest version of these files instead of any old ones that might still be around. We're working on the dedicated merging mechanism that will allow to optimize the caching process even more.
Runtime & module iterations
The iterations option limits how often the module regenerates flattened content and vectors when Nuxt repeatedly emits templates - leave it aligned with how often you actually need refreshed search assets.
Parsings
When indexing content for search, DocLayer processes each page as it will appear on your site, organizing everything by page and its sections for precise search results. Inline code snippets (backticks) are kept in the text, while large blocks of code or excluded sections are not included in the main index - but can still be referenced by search and the AI Assistant. Content is automatically cleaned and formatted for smooth, readable search results. You can easily exclude specific parts of your content (like tags or sections) using exclusions. DocLayer also handles most formatting issues automatically, skipping and reporting any problem areas so your site and search features keep working without interruption.
Code References
During the authoring process, indexed content may include cref metadata tags that act as code references. The internal algorithm resolves these references and writes them to corresponding files at public/.doclayer/cref directory, each containing the language type indicator and the associated stringified code.
Why does DocLayer do this? Within the searchable AST pipeline, DlCode subtrees are replaced by these special reference nodes. This means embeddings and context outputs can indicate which specific code snippet applies - without duplicating large chunks of code in every vector. This approach is both faster and more efficient, since code references are stored and retrieved separately rather than embedding full snippets everywhere. Furthermore - and perhaps even more importantly - directly embedding code blocks can cause formatting errors, and processing them with tools like Shiki may introduce significant overhead to content preparation and storage (if enabled).
Finally, the context that the AI Assistant uses is intentionally stripped of large code blocks, which are loaded asynchronously only when needed. This approach ensures the entire process remains efficient and reliable. This is why using the DlCode component is so important for building smart content indexing.
Excluding code blocks from being indexed
If you need to exclude certain code blocks from being indexed and saved as code references, add [[ esc ]] tags around the code block.
AI Kit
As mentioned above, along with the remote-based model(s) (remote or dl) you can use a dedicated AI Kit, which includes advanced features such as the enhanced Chat component, content caching, conversation history, and more.
AI Kit (@vuehouse/dl-ai-kit) is a standalone Nuxt module that - when added - will automatically detect it's surroundings and enable the necessary features based on the presence of the dl-search module. You can add it to your application by running:
Module-provided Chat interfaces replaces the default Assistant, that operates with a local models. It doesn't need any further configuration.
In the end add source for Tailwind to recognize the new components and its styles. In you styles.css file, add the following:
Logging
During both runtime and build time, the dl-search module logs various activities to the terminal. The module will provide information about the preparation process. Monitor these logs also to identify any issues that may arise. Additionally, it includes mechanisms to notify you of any problems encountered during content parsing, such as which sections or pages are affected and may require corrections to formatting.
Here is an example of the logs that you may see in the terminal:
