Is Nuxt3 the ideal choice for generating static sites with specific pages?

Can server-side rendering be implemented for a specific page in Nuxt?

This is my desired outcome

Server-Side Rendered Page: www.example.com/foo

Client-Side Rendered Page: www.example.com/bar

Answer №1

Check out my answer on this topic. In Nuxt3, you can still use the exclude key to achieve a mix of SSG and SPA.

For example, have some pages as static (/) and others as dynamic (/about).

/pages/index.vue

<template>
  <div>
    This is the default index page, visible without JS
  </div>
</template>

/pages/about.vue

<template>
  <div>
    The about page is only accessible with JS enabled
  </div>
</template>

nuxt.config.js

export default defineNuxtConfig({
  ssr: true,
  generate: {
    exclude: [
      /^\/about/
    ]
  }
})

You can test this by disabling JS in your browser's devtools or inspecting the source code to see that the /about page lacks statically generated content (meaning it requires JS).


There are plans for a syntax like the one mentioned here:

export default defineNuxtConfig({
  routes: {
    '/': { prerender: true }, 
    '/blog/*': { static: true }, 
    '/stats/*': { swr: '10 min' },
    '/admin/*': { ssr: false }, 
    '/react/*': { redirect: '/vue' }, 
  }
})

However, these features are still in development. For now, I recommend sticking to the current method of achieving this functionality.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Transforming Data-Attributes into an Array Using jQuery in a Plugin: A Step-by-Step Guide

Currently, I am attempting to extract attributes from specific selection tags using the following code: $('tagName').swapper(); Each section contains data-image="source". My objective is to retrieve each of these attributes and arrange them int ...

Updating input field value with JavaScript

I am working with two textboxes <input id='random_value' name='random_name' value='First' <input id='random_value' name='random_name' value='' My challenge is to replace the value of a tex ...

Is it possible to expand the CORS permissions to the routers directly from the app?

I have a couple of questions: Is it possible to just use cors() once in my server.js instead of having to call and use it in every router file? Can I simply require express once in my server.js without having to call it in all my router files? Currently, ...

Automating Image Downloads with Puppeteer by Adding Authentication Query String to Image URL

Attempting to save images stored in a web-space account can be challenging. Accessing the private space with credentials and retrieving the image link using Puppeteer works smoothly. However, when the src attribute of the image includes additional authenti ...

Switch between toggling tasks in Vue does not seem to be functioning as

I'm reaching out again because I'm struggling to figure out what I'm doing wrong. I followed a tutorial step by step but the code isn't working as expected. My goal is to toggle between marking tasks as done and not done. When I test th ...

The Filepond input field is not properly linked to the form data during the sending process

I am having trouble uploading a FilePond file field to the server along with other form elements. My form consists of input fields, a select field, a textarea, and a file input field connected to the Filepond plugin. <form class="uploadform"& ...

What is the best way to retrieve text from a textbox and assign it to a variable for sending it in an AJAX 'POST' request?

I need to store the text input from the 'txtDATE' textbox in a variable called press_date. The current AJAX post function is working fine, but I need to make the value dynamic instead of static. I've spent all day searching for solutions and ...

The local storage is unavailable on Chrome Mobile due to null value being

My error reporting system is detecting issues with JS Web Storage failures specifically on Android devices using Chrome mobile. Interestingly, I have not been able to replicate this error on my own Android device. The error message that keeps popping up i ...

Issue with Ajax communication to PHP script causing data not to be sent

I am developing a web application that functions as an extensive form which will later be converted into a PDF document. Upon submission of the form, all input data is sent to a PHP file where they are stored as variables to be included in the PDF. Some of ...

Error encountered when adding a new query to vue-router causes navigation duplication

When I use the following command, I push a query to the router: this.$router.push({ query: { queryKey: ["a", "b", "c"] } }); Every click on an element adds a new value to the array. So, the first query is "a", then ["a", "b"], and finally ["a", "b", "c"] ...

Sending numerous messages from a single event using Socket.io

After an exhaustive search, I have yet to find a solution to my problem. I am attempting to send a message from the server every time it detects a file change in a specific directory. However, instead of sending just one message, it sends the same message ...

Every time I attempt to make a "post" request to the SailsJS server, I encounter a 403 CSRF Mismatch error

Having an issue with my sailsJS server. I am attempting to send a post request from a client on a different domain. I am sending _csrf from /csrfToken, but encountering a 403 csrf mismatch repeatedly. The client-side code appears as follows: $.ajax( ...

Exploring ways to create fresh arrays derived from the original array

On our company website, we have a wide array of vehicles available for purchase. Among these vehicles, there is a specific group of vans with detailed information such as the model and value. {vanNumber: "7654628", vanDescription: "VW Campervan", value: { ...

currentTimestamp().convertToReadableFormat()

It feels like I'm spending too much time on this. I've been trying to format the momento().toDate() in pt format but no luck so far. I've already added it to my react code import 'moment/locale/pt'; import moment from 'momen ...

Showing information from a database while incorporating line breaks with the help of nl2br

Having trouble with the previous question, so I'll provide more detail here. Below is my index.php file where I explain the method used to save data to a database. <html> <head> <script> function updategroup() { var update_c ...

Incorporating Font Awesome into a Vue.js project

I followed the instructions in the Vue project documentation to install font-awesome, but encountered an error: https://i.sstatic.net/c6rAW.png Initially, I used the following commands for installation: $ npm i --save @fortawesome/fontawesome-svg-core $ n ...

Uh oh! AngularJS just threw an error: Uncaught TypeError - angular.service is not a function. It happened in taskService.js

I've run into some issues with AngularJS, even though I have imported all the necessary libraries. Specifically, I am encountering the following errors: Uncaught TypeError: angular.service is not a function at taskService.js:2 taskFactory. ...

Issue encountered when making API requests in JavaScript that is not present when using Postman

Currently, I am developing a web application using express and one of the functionalities is exposed through an API with an endpoint on 'api/tone'. This API acts as a wrapper for one of Watson's services but I choose not to call them directl ...

Is there a way to delete a table's row using JavaScript?

Hey there, total newbie to coding here. I'm working on a simple to do list project. The adding function is working great, and here's the code for it: let salvar = document.getElementById("salvar") let remove = document.getElementById("remove ...

I am having trouble with my jQuery datatable Ajax call - instead of reaching the server, I am seeing an alert indicating

Looking for help with my web page. I have a table that needs to be populated using AJAX calls to the server-side method. I've implemented jQuery DataTables, and here's the code snippet: $(document).ready(function() { $("#tableUserList").DataTa ...